简体   繁体   中英

Pandoc, markdown to pdf doesn't wrap long words in paragraphs

I'm trying to generate a clean PDF from markdown using Pandoc and xelatex.

When I convert :

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

I end up having :

文字溢出

Here is the command I use to generate the PDF :

/usr/local/bin/pandoc --verbose \
--chapters --from=markdown+yaml_metadata_block -S \
--latex-engine=xelatex \
--listings -H listings-setup.tex \
--template template.pdf \
--toc --chapters \
-o test.pdf \
metadata.yml \
test.md

I use the document class : report

I have tried different things from inside the template and the extra header I'm using but I have now idea what template is Pandoc using when generating paragraphs.

I see under my template.pdf (extracted from Pandoc), but doesn't seem to apply here :

\setlength{\emergencystretch}{3em}  % prevent overfull lines

You've a few possibilities. Since pandoc uses LaTeX for PDF generation, these are adapted from this LaTeX answer :

  1. Annotate the proper language:

     --- lang: en-GB --- rest of document 
  2. use soft hyphens inside a word to explicitly denote the allowed places to break. You can either use the unicode character or the HTML entity ­ which pandoc will convert automatically for LaTeX etc. For example; cryp­to­graphy

  3. Specify exceptions via \\hyphenation{cryp-to-graphy}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM