英文:
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 \
"$md_file" \
--pdf-engine=pdflatex \
--variable=geometry:a4paper \
--variable=fontsize=12pt \
--output "${md_file%.md}.pdf"
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 <return> 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="\\hyphenpenalty=10000 \\exhyphenpenalty=10000" ...
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论