如何将 `hyphenpenalty` 作为命令行参数传递给 Pandoc?

huangapple go评论95阅读模式
英文:

How to pass `hyphenpenalty` as a CLI parameter to Pandoc?

问题

I want to convert MD to PDF with Pandoc and pdflatex:

  1. pandoc \
  2. "$md_file" \
  3. --pdf-engine=pdflatex \
  4. --variable=geometry:a4paper \
  5. --variable=fontsize=12pt \
  6. --output "${md_file%.md}.pdf"

How do I disable hyphenation using a CLI parameter?

I've tried to set it within the markdown file, as a YAML metadata block, and it's working:

  1. ---
  2. header-includes: |
  3. \hyphenpenalty=10000
  4. \exhyphenpenalty=10000
  5. ---
  6. The rest of the markdown file

But… I want the settings for multiple files and I do not want to "hardcode" them inside the markdown file, so I've extracted the above to a dedicated pdf_config.yml file, and it is also working:

  1. header-includes: |
  2. \hyphenpenalty=10000
  3. \exhyphenpenalty=10000
  1. pandoc
  2. --metadata-file ./pdf_config.yml \

Finally, I do not want an extra YAML file -> I want everything in my bash script -> so, I want to pass the metadata by a CLI parameter. I've tried multiple variations of the below, with no success:

  1. pandoc
  2. --metadata=header-includes:hyphenpenalty=10000 \
  3. --metadata=header-includes:exhyphenpenalty=10000
  1. Error producing PDF.
  2. ! LaTeX Error: Missing \begin{document}.
  3. See the LaTeX manual or LaTeX Companion for explanation.
  4. Type H <return> for immediate help.
  5. ...
  6. l.45 h
英文:

I want to convert MD to PDF with Pandoc and pdflatex:

  1. pandoc \
  2. &quot;$md_file&quot; \
  3. --pdf-engine=pdflatex \
  4. --variable=geometry:a4paper \
  5. --variable=fontsize=12pt \
  6. --output &quot;${md_file%.md}.pdf&quot;

How do I disable hyphenation using a CLI paramter?


I've tried to set it within the markdown file, as a YAML metadata block, and it's working:

  1. ---
  2. header-includes: |
  3. \hyphenpenalty=10000
  4. \exhyphenpenalty=10000
  5. ---
  6. The rest of the markdown file

But… I want the settings for multiple files and I do not want to "hardcode" them inside the markdown file, so I've extracted the above to a dedicated pdf_config.yml file, and it is also working:

  1. header-includes: |
  2. \hyphenpenalty=10000
  3. \exhyphenpenalty=10000
  1. pandoc
  2. --metadata-file ./pdf_config.yml \

Finally, I do not want an extra YAML file -> I want everything in my bash script -> so, I want to pass the metadata by a CLI parameter. I'v tried multiple variations of the below, with no success:

  1. pandoc
  2. --metadata=header-includes:hyphenpenalty=10000 \
  3. --metadata=header-includes:exhyphenpenalty=10000 \
  1. Error producing PDF.
  2. ! LaTeX Error: Missing \begin{document}.
  3. See the LaTeX manual or LaTeX Companion for explanation.
  4. Type H &lt;return&gt; for immediate help.
  5. ...
  6. l.45 h

答案1

得分: 2

将元数据值 header-includes 的设置改为相同名称的变量:

  1. pandoc -V header-includes="\\hyphenpenalty=10000 \\exhyphenpenalty=10000" ...

这将按原样插入文档中。

英文:

Instead of setting the header-includes metadata value, set the variable of the same name instead:

  1. pandoc -V header-includes=&quot;\\hyphenpenalty=10000 \\exhyphenpenalty=10000&quot; ...

This will be inserted into the document verbatim.

答案2

得分: -2

你应该使用命令行标志“-rHY=0”将HY寄存器设置为值0。

然后通过命令行参数传递元数据。

英文:

You should pass the HY register with the value 0 with the -rHY=0 command line flag.

Then pass the metadata by a CLI parameter.

huangapple
  • 本文由 发表于 2023年5月24日 19:49:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76323201.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定