如何使 markdown 包与 LuaLaTeX 一起工作?

如何使 markdown 包与 LuaLaTeX 一起工作?

我想使用该markdown包在我的 LaTeX 文档中重复使用一些 markdown 片段。

我遵循文档并创建main.tex

\documentclass{article}
\usepackage{markdown}
\begin{document}
    \begin{markdown}
        Hello *world*!
    \end{markdown}
\end{document}

然后,我运行lualatex main.tex

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022) 
 restricted system commands enabled.
(./main.tex
LaTeX2e <2022-11-01> patch level 1
 L3 programming layer <2023-02-07>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/markdown/markdown.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def))
(/usr/local/texlive/2022/texmf-dist/tex/generic/markdown/markdown.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/lt3luabridge/lt3luabridge.tex))
(/usr/local/texlive/2022/texmf-dist/tex/latex/paralist/paralist.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/csvsimple/csvsimple.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
) (/usr/local/texlive/2022/texmf-dist/tex/latex/csvsimple/csvsimple-legacy.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
) (/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeyslibraryfil
tered.code.tex))) (/usr/local/texlive/2022/texmf-dist/tex/latex/base/ifthen.sty
) (/usr/local/texlive/2022/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/tools/shellesc.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-def/luatex.def)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/gobble/gobble.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/gobble/gobble.tex))
(/usr/local/texlive/2022/texmf-dist/tex/latex/url/url.sty))
No file main.aux.
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/local/texlive/2022/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2022/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./_markdown_main/0f7a4d6cf80efde3bcdf53b9fbb39890.md.tex) [1{/usr/local/texliv
e/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./main.aux))
 504 words of node memory still in use:
   6 hlist, 2 vlist, 2 rule, 2 glue, 4 kern, 1 glyph, 6 attribute, 56 glue_spec
, 6 attribute_list, 1 write nodes
   avail lists: 1:1,2:31,3:4,4:1,5:23,7:72,9:28
</usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.
otf></usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm/lmmono10-regul
ar.otf>
Output written on main.pdf (1 page, 4620 bytes).
Transcript written on main.log.

我得到的结果就是这样(与 相同pdflatex --shell-escape):

在此处输入图片描述

如何让 markdown 格式起作用?

答案1

\begin{verbatim}…\end{verbatim}问题在于你对缩进的使用,因为 markdown 中 4 个空格(或更多)的缩进与 LaTeX 或HTML 中的缩进相同<pre>…</pre>。因此只需删除缩进:

\documentclass{article}
\usepackage{markdown}
\begin{document}
\begin{markdown}
Hello *world*!
\end{markdown}
\end{document}

要得到

在此处输入图片描述

相关内容