llmk: 新時代の LaTeX 文書ビルドツール / llmk

874fb6168eaee95c155b850a934de418?s=47 Watson
November 10, 2018

llmk: 新時代の LaTeX 文書ビルドツール / llmk

874fb6168eaee95c155b850a934de418?s=128

Watson

November 10, 2018
Tweet

Transcript

  1. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ TEXConf 2018 Ұൠߨԋ llmk: ৽࣌୅ͷ

    L A TEX จॻϏϧυπʔϧ ே૔୎ਓ (wtsnjp) 2018 ೥ 11 ݄ 10 ೔ 1 / 23
  2. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ L A TEX จॻͷϏϧυखॱᶃ ໰୊

    ҎԼͷ L A TEX จॻͷϏϧυखॱΛਪଌ͍ͯͩ͘͠͞ɿ $ tree . ᵓᴷᴷ duck.tex ᵓᴷᴷ essential.tex ᵓᴷᴷ essential.bib ᵋᴷᴷ snowman.tex ▶ Ͳͷ TEX ϑΝΠϧΛʁ Ͳͷ TEX ΤϯδϯͰʁ ▶ BibTEX ͷ࣮ߦ͸ඞཁʁ ΋͔ͯ͠͠ Biberʁ ▶ Makeindex ͸ʁ ελΠϧ (*.ist) ͷࢦఆ͸ʁ 2 / 23
  3. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ L A TEX จॻͷϏϧυखॱᶄ ਖ਼ղʢʁʣ

    $ uplatex essential.tex & uplatex essential.tex $ bibtex essential $ makeindex -s gind.ist essential.idx $ uplatex essential.tex & uplatex essential.tex $ dvipdfmx essential.dvi ▶ ຖճखͰίϚϯυΛଧͭͷ͸໘౗͍͘͞ʜʜ ▶ ͜ͷ৘ใΛڞஶऀͳͲୈࡾऀʹڞ༗͢Δʹ͸ʁ ▶ Ϋϥ΢υγεςϜ΍૊൛༻αʔόΛར༻͢Δ৔߹͸ʁ ྫ ͜ͷϑΝΠϧߏ੒Ͱ arXiv ΞοϓϩʔυΛࢼΈΔͱɼAutoTEX ͕ ͢΂ͯͷ ‌‌ *.tex ͷίϯύΠϧΛࢼΈͯΤϥʔʹͳΔɽ L A TEX จॻͷϏϧυखॱ͸ϑΝΠϧߏ੒͔Βࣗ໌Ͱ͸ͳ͍ʂ 3 / 23
  4. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ L A TEX จॻͷϏϧυखॱᶅ llmk

    Λ࢖͏ͱʜʜʂʁ 1. ࣍ͷ಺༰Λ llmk.toml ʹอଘ 1 source = "essential.tex" 2 latex = "uplatex" 3 4 [programs.makeindex] 5 opts = "-s gind.ist" 2. llmk ίϚϯυΛ࣮ߦ $ llmk 4 / 23
  5. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ طଘπʔϧͷ໰୊఺ latexmk ઃఆهड़ΛӅ͠ϑΝΠϧ ‌‌ .latexmkrc

    ʹߦ͏ʢ৔߹͕͋Δʣ ࣮ߦ͞ΕΔॲཧ͕؀ڥʹΑΓҟͳΔʢϢʔβઃఆͷӨڹʣ ઃఆهड़ͷܗ͕ࣜ Perl ݴޠ ▶ ͦ΋ͦ΋ʮจॻ͝ͱʹϏϧυखॱΛ໌ࣔ͢΂͖ʯͱ͍͏ઃܭ ࢥ૝Ͱ։ൃ͞Ε͍ͯͳ͍ arara ࣮ߦ͞ΕΔॲཧ͕؀ڥʹΑΓҟͳΔʢϧʔϧͷಠࣗఆٛʣ ಈ࡞ʹ JVM ͕ඞཁ ͦͷଞ ͦ΋ͦ΋ແ໊Ͱ͋Δ → ϏϧυखॱΛڞ༗͢Δํ๏͕ඪ४Խ͞ΕΔ΂͖ 5 / 23
  6. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ llmk ͷجຊతͳಛ௃ ▶ ઃܭࢥ૝ɿϏϧυखॱ͸ϓϩδΣΫτ͝ͱʹ໌ࣔ͢΂͖ ▶

    texlua Ͱ࣮ߦՄೳʹΫϩεϓϥοτϑΥʔϜ ▶ Ϗϧυखॱهड़ͷܗࣜʹ TOML Λ࠾༻ ▶ Ϗϧυखॱͷهड़Λָʹ͢ΔσϑΥϧτઃఆ 6 / 23
  7. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ઃఆهड़ݴޠ TOML ᶃ ֓ཁ TOML:

    Tom’s Obvious, Minimal Language ▶ Tom Preston-WernerʢGitHub ͷதͷਓʣ͕ఏҊ ▶ ઃఆهड़ʹಛԽͨ͠ϛχϚϜݴޠ cf. XML, JSON, YAML ▶ ਓ͕ؒಡΈॻ͖͠΍͍͢ ▶ ύʔαΛॻ͘ͷ΋؆୯ → llmk ༻ʹϑϧεΫϥον࣮૷ https://github.com/toml-lang/toml TOML Λ࠾༻͢ΔϓϩδΣΫτ ▶ Vim ͷϓϥάΠϯϚωʔδϟ NeoBundle, dein.vim ▶ ੩తαΠτδΣωϨʔλ Hugo 7 / 23
  8. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ઃఆهड़ݴޠ TOML ᶄ جຊ࢓༷ جຊతͳΠϝʔδ͸ʮߦࢦ޲ͷ

    key=valʯ ʢINI ͷൃల൛ʁʣ ▶ ίϝϯτʢ# ‌‌ ͔Βߦ຤ʣ ɼΠϯσϯτࣗ༝ɼΩʔͷॏෳෆՄ ▶ جຊతͳσʔλܕ ˞੺ࣈ͸ݱ࣌఺Ͱ llmk ະαϙʔτ ▶ จࣈྻʢશ 4 छɽΤεέʔϓॲཧͱෳ਺ߦจࣈྻ͸ະ࣮૷ʣ ▶ ੔਺ɼුಈখ਺఺਺ɼ೔෇ ▶ ϒʔϧ஋ ྫ 1 # จࣈྻ 2 key = "value" # "str" ͸ΤεέʔϓՄೳɼ’str’ ͸ verbatim 3 4 # ੔਺ 5 answer = 42 6 7 # ϒʔϧ஋ 8 TeX_is_obsolete = true 8 / 23
  9. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ઃఆهड़ݴޠ TOML ᶅ σʔλߏ଄ ▶

    ഑ྻɿཁૉΛΧϯϚ۠੾ΓͰهड़ɽσʔλܕͷࠞࡏ͸ෆՄ ▶ ςʔϒϧɿ͍ΘΏΔࣙॻʢϋογϡʣ ɽॱংอূͳ͠ ▶ ΠϯϥΠϯɾςʔϒϧɼςʔϒϧͷ഑ྻ ྫ 1 # ഑ྻ 2 texconf = [ "Tokyo", "Fukuoka", "Fujisawa", "Sapporo" ] 3 4 # ςʔϒϧ 5 [snowman] # ࣍ͷςʔϒϧ·ͨ͸ EOF ·Ͱ snowman ςʔϒϧͷ key=val 6 hat = "green" 7 snow = true 8 9 # ςʔϒϧͷωετ 10 [duck.queen] 11 color = "pink" 12 # JSON: { "duck": { "queen": { "color": "pink" } } } 9 / 23
  10. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ llmk ͷجຊతͳ࢖͍ํᶃ Ϗϧυखॱͷهड़৔ॴ ઐ༻ϑΝΠϧ ▶

    ϑΝΠϧ໊͸ llmk.toml Ͱݻఆʢ࢑ఆʣ ▶ llmk ίϚϯυΛҾ਺ͳ͠Ͱ࣮ߦ͢ΔͱɼࣗಈతʹಡΈࠐΈ L A TEX จॻιʔεͷίϝϯτ ▶ ‌ +++ ‌ ʹڬ·ΕͨίϝϯτྖҬʢTOML ϑΟʔϧυʣ ▶ llmk ίϚϯυͷҾ਺ʹ༩֤͑ͨϑΝΠϧʹ͍ͭͯಡΈࠐΈ ྫ 1 % +++ 2 % latex = "xelatex" 3 % +++ 4 \documentclass{article} 5 \begin{document} 6 Hello llmk! 7 \end{document} 10 / 23
  11. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ llmk ͷجຊతͳ࢖͍ํᶄ ୯७ͳઃఆΩʔ ▶ latex

    (string): ࢖༻͢Δ L A TEX Τϯδϯʢطఆɿlualatexʣ → dvipdf, bibtex ΩʔͳͲ΋ಉ༷ʹଘࡏ ▶ max_repeat (int): ܁Γฦ࣮͠ߦͷ্ݶʢنఆɿ3ʣ ▶ source (string or array of strings): จॻιʔε → ͜ͷΩʔ͸ llmk.toml ಺ͰͷΈ༗ޮ͔ͭඞਢ ྫ 1 # ॲཧର৅ 2 source = [ "test1.tex", "test2.tex" ] 3 4 # ࢖༻ϓϩάϥϜ 5 latex = "xelatex" 6 bibtex = "biber" 7 8 # ܁Γฦ͠ͷ্ݶ 9 max_repeat = 5 11 / 23
  12. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ॊೈͳ੍ޚᶃ sequence & programs ▶

    sequence (array of strings): ϓϩάϥϜ໊Λ࣮ߦॱʹࢦఆ ▶ programs (table of tables): ֤ϓϩάϥϜͷৄࡉͳઃఆ sequence ͷྫ " latex " → " bibtex " programs ͷྫ latex command: "xelatex" auxiliary: "foo.aux" opts: "-recorder" bibtex command: "bibtex" target: "foo.bib" postprocess: " latex " 12 / 23
  13. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ॊೈͳ੍ޚᶄ programs ςʔϒϧ ֤ program

    ςʔϒϧʹࢦఆՄೳͳΩʔ ▶ command (string): ࣮ߦ͢ΔίϚϯυ ▶ target (string): ର৅ϑΝΠϧ͕ଘࡏ͢Ε͹ίϚϯυ࣮ߦ ▶ opts (string or array of strings): ίϚϯυϥΠϯΦϓγϣϯ ▶ args (string or array of strings): ίϚϯυϥΠϯҾ਺ ▶ auxiliary (string): ؂ࢹର৅ϑΝΠϧ ▶ postprocess (string): ޙॲཧϓϩάϥϜʢ࣮ߦ࣌ͷΈʣ ಛผͳࢦఆࢠ target, opts, args, auxiliary ΩʔͰ͸ҎԼͷࢦఆࢠ͕࢖͑Δɽ ▶ %S: ॲཧதͷιʔεϑΝΠϧύεʢೖྗͦͷ΋ͷʣ ▶ %T: ֤ϓϩάϥϜͷ targetʢtarget ΩʔͰ͸ڍಈະఆٛʣ ▶ %B: %S ͷ basenameʢ֦ுࢠΛམͱͨ͠΋ͷʣ 13 / 23
  14. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ༨ஊɿΫʔϧͳϓϩδΣΫτʹ͸ϩΰ͕ඞཁ llmk ͷϩΰ ▶ sequence

    ͕Ϟνʔϑ ▶ ΋ͪΖΜ TikZ ੡ ▶ llmk Ͱॲཧ͢Δͱɼ TEX2img Ͱ PNG ੜ੒ ଞͷϓϩδΣΫτͷϩΰʢࢀߟʣ 14 / 23
  15. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ σϑΥϧτઃఆᶃ جຊతͳߟ͑ํ ▶ ຖճθϩ͔Β sequence,

    programs Λهड़͢Δͷ͸େม → ඪ४తͳέʔεͰ͏·͍͘͘σϑΥϧτઃఆΛఏڙ ▶ ͍ΘΏΔϢʔβઃఆ͸ೝΊͨ͘ͳ͍ ∵ʮಉҰιʔε͔Β͸ৗʹಉҰͷ݁ՌʯΛอূ͍ͨ͠ ▶ TOML ʹهड़ͨ͠಺༰ͰσϑΥϧτઃఆΛ্ॻ͖͢Δ → ڍಈͷਪଌ͕೉͘͠ͳΔڪΕ ▶ Ϗϧυखॱͷσόοάग़ྗͳͲΛॆ࣮Խͯ͠ରԠ ▶ σϑΥϧτΛແޮԽ͢ΔΩʔͷ௥ՃΛݕ౼த σϑΥϧτ sequence " latex "→" bibtex "→" makeindex "→" dvipdf " 15 / 23
  16. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ σϑΥϧτઃఆᶄ σϑΥϧτ programsʢൈਮʣ latex command:

    "lualatex" auxiliary: "%B.aux" dvipdf command: "dvipdfmx" target: "%B.dvi" bibtex command: "bibtex" target: "%B.bib" postprocess: " latex " makeindex command: "makeindex" target: "%B.idx" postprocess: " latex " ▶ ্هҎ֎ʹ΋ dvips, ps2pdf ͷطఆ஋͋ΓʢREADME ࢀরʣ ▶ ࠓޙ΋ඞཁʹԠͯ͡௥Ճ͢Δ༧ఆ → ϦΫΤετड෇தʂ 16 / 23
  17. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ۩ମతͳهड़ྫ dvips Λ࢖͍͍ͨ programs ʹ͸نఆ͕͋ΔͷͰɼsequence

    ͚ͩมߋ͢Ε͹े෼ɽ 1 # LaTeX Τϯδϯ͸ pLaTeX Λ࢖༻ 2 latex = "platex" # ࣮͸ [programs.latex] ͷ command Ωʔ΁ͷলུܗ 3 4 # dvipdf Ͱ͸ͳ͘ ps ܦ༝Ͱ PDF Λੜ੒͍ͨ͠ 5 sequence = [ "latex", "dvips", "ps2pdf" ] ࡞ۀσΟϨΫτϦΛԚͨ͘͠ͳ͍ ͋·Γχονͳधཁ΍ɼෳࡶͳϩδοΫ͸ llmk Ͱ͸ରԠ͠ͳ͍ → llmk ͔Β֎෦πʔϧΛݺͼग़͢࢖͍ํ΋ΞϦ 1 # ઐ໳ͷπʔϧ ClutTeX ʹؙ౤͛ 2 sequence = [ "cluttex" ] 3 4 [programs.cluttex] 5 command = "cllualatex" 17 / 23
  18. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ طଘܗࣜͷαϙʔτ TOML ܗࣜͰͷϏϧυखॱهड़๏͸ɼllmk ͷͨΊ৽نʹઃܭͨ͠ ΋ͷ͕ͩɼ࣮͸͍͔ͭ͘Α͘࢖ΘΕ͍ͯΔطଘܗ͕ࣜ͋Δɽ

    γΣόϯάʢ ‌ %# ‌ ه๏ͷҰछʣ ▶ ओͳ࠾༻ιϑτ΢ΣΞɿYaTeX ▶ llmk ͰαϙʔτࡁΈ %#!uplatex latex = "uplatex" ϚδοΫίϝϯτ ▶ ओͳ࠾༻ιϑτ΢ΣΞɿTeXShop, TeXworks, TeXstudio ▶ llmk Ͱαϙʔτ༧ఆ %!TEX program = pdflatex %!BIB program = biber latex = "pdflatex" bibtex = "bibtex" 18 / 23
  19. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ૝ఆ͢Δར༻έʔε llmk ͸ CLI πʔϧͱͯ͠ͷར༻ʹͱͲ·ΒͣɼL

    A TEX จॻͷϏϧυ Λඞཁͱ͢Δ༷ʑͳ৔໘Ͱར༻͞ΕΔ͜ͱΛ૝ఆ͍ͯ͠Δɽ ▶ ߴػೳςΩετΤσΟλ΍౷߹։ൃ؀ڥ ▶ L A TEX ؔ࿈ͷΫϥ΢υαʔϏε ▶ ૊൛ઐ༻αʔόͰͷόονॲཧ 19 / 23
  20. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ Α͋͘Δ࣭໰ (n = 1) llmk

    ͸ L A TEX ઐ༻͔ʁ ੍ޚػߏ͕े෼ॊೈͳͷͰɼͦͷؾʹͳΕ͹ͲΜͳϓϩδΣΫτ ͷϏϧυʹ΋࢖༻Մೳɽͨͩ͠ ▶ TOML ϑΟʔϧυͷ࢓༷͸ TEX ͕લఏ ▶ σϑΥϧτઃఆ (sequence, programs) ͕ L A TEX ʹ࠷దԽ ηΩϡϦςΟ͸ʁ ଞͷϏϧυπʔϧͱಉఔ౓͔ͦΕҎ্ɽ ▶ ͦ΋ͦ΋ϏϧυπʔϧҰൠ͕҆શͰͳ͍ ∵ ೚ҙͷίϚϯυΛ࣮ߦՄೳ ▶ llmk ͸ৗʹઃఆΛ 1 Օॴʹهड़͢ΔͷͰɼνΣοΫ͕༰қ ωοτͰೖखͨ͠ϑΝΠϧΛ֬ೝͤͣʹ llmk Ͱॲཧ͠ͳ͍ʂ 20 / 23
  21. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ Πϯετʔϧํ๏ͱݱঢ় Πϯετʔϧํ๏ 1. https://github.com/wtsnjp/llmk ͔Βιʔεೖख

    2. ୯७ʹ texlua llmk.lua Λ࣮ߦʢ୯ମϑΝΠϧʣ ݱࡏͷόʔδϣϯɿv0.1 ▶ ͢΂ͯͷ࢓༷͸ v1.0 ·Ͱ͸ഁյతʹมߋ͞ΕಘΔ ▶ v1.0 ·Ͱʹ࣮૷༧ఆͷओཁͳػೳ͸࣮૷ࡁΈ → όά֬ೝɼࡉ͔͍ػೳ࣮૷ͱϦϑΝΫλϦϯά͕ඞཁ ▶ υΩϡϝϯτ͸࣮࣭తʹ README ͷΈ ▶ examples σΟϨΫτϦʹαϯϓϧଟ਺ 21 / 23
  22. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ࠓޙͷํ਑ ݕ౼ࣄ߲ ▶ ΤϯίʔσΟϯάɽUTF-8 Ҏ֎ΛͲ͏͢Δ͔ʁ

    ▶ લճ࣮ߦ͔࣌ΒϑΝΠϧมߋ͕͔͋ͬͨͲ͏͔΋ݕग़ʁ → ֎෦ϑΝΠϧ (foo.llmk_fdb) ΁ͷॻ͖ग़͕͠ඞཁ ▶ TOML ೖྗʹ͍ͭͯɼࣄલͷܕνΣοΫ ϩʔυϚοϓʢ͋͘·Ͱ༧ఆʣ ▶ 2019-07-25 TEX Development Fund ظݶ ▶ ͜͜·Ͱʹ v1.0 ΛϦϦʔε ▶ CTAN ʹΞοϓϩʔυ ▶ 2019-08-09 TUG2019 (CA, USA) ▶ ޱ಄ൃදΛݕ౼த ▶ TUGboat هࣄ΋ࣥච͍ͨ͠ 22 / 23
  23. llmk: ৽࣌୅ͷ L ATEX จॻϏϧυπʔϧ ·ͱΊ ▶ Ϗϧυखॱ͸จॻ͝ͱʹ໌ࣔ͞ΕΔ΂͖ɽಛʹ ▶ ୈࡾऀͱݪߘΛڞ༗͢Δ৔߹

    ▶ Ϋϥ΢υαʔϏε΍૊൛ઐ༻αʔόར༻ͷ৔߹ ▶ ্Λઃܭࢥ૝ͱͯ͠ llmk ͱ͍͏৽͍͠πʔϧΛ։ൃ ▶ texlua Ͱ࣮ߦͰ͖ɼΫϩεϓϥοτϑΥʔϜ ▶ Ϗϧυखॱهड़ͷܗࣜ͸ TOML ▶ खॱ໌ࣔ೿͕ͩɼهड़Λָʹ͢ΔσϑΥϧτઃఆ͕͋Δ → llmk Ͱॲཧ͢ΔݶΓৗʹ݁Ռ͕ಉ͡Ͱ͋Δ͜ͱΛॏཁࢹ ँࣙ llmk ϓϩδΣΫτ͸ TUG ͷ TEX Development Fund ʹΑΓࢧԉΛ ड͚͍ͯ·͢ɽKarl, Norbert ͸͡Ίؔ܎ऀ֤Ґʹײँ͠·͢ɽ 23 / 23