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

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

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

问题

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

pandoc \
  "$md_file" \
  --pdf-engine=pdflatex \
  --variable=geometry:a4paper \
  --variable=fontsize=12pt \
  --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:

---
header-includes: |
  \hyphenpenalty=10000
  \exhyphenpenalty=10000
---

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:

header-includes: |
  \hyphenpenalty=10000
  \exhyphenpenalty=10000  
pandoc
  --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:

pandoc
  --metadata=header-includes:hyphenpenalty=10000 \
  --metadata=header-includes:exhyphenpenalty=10000
Error producing PDF.
! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                              
l.45 h
英文:

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

pandoc \
  &quot;$md_file&quot; \
  --pdf-engine=pdflatex \
  --variable=geometry:a4paper \
  --variable=fontsize=12pt \
  --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:

---
header-includes: |
  \hyphenpenalty=10000
  \exhyphenpenalty=10000
---

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:

header-includes: |
  \hyphenpenalty=10000
  \exhyphenpenalty=10000  
pandoc
  --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:

pandoc
  --metadata=header-includes:hyphenpenalty=10000 \
  --metadata=header-includes:exhyphenpenalty=10000 \
Error producing PDF.
! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H &lt;return&gt;  for immediate help.
 ...                                              
                                                  
l.45 h

答案1

得分: 2

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

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

这将按原样插入文档中。

英文:

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

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:

确定