Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using pandoc markdown to generate PDF, and I cannot get it to accept my special characters.

For example, I want to include Mah\={a}v\={\i}ra in my document to place macrons over the appropriate letters. When I publish:

pandoc -o mydoc.pdf mydoc.md

I my document contains Mah={a}v={i}ra. The dot has been stripped from the i, as I requested by using \i, but the \= was just converted to =.

A few tests with similar accent characters is revealing the same problem.

How can I get macron accents into my document?

share|improve this question

closed as off topic by egreg, Kurt, Claudio Fiandrino, Marco Daniel, Thorsten Feb 14 '13 at 17:19

Questions on TeX - LaTeX Stack Exchange are expected to relate to TeX, LaTeX or related typesetting systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Pandoc is only on-topic for us when there is a strong (La)TeX link: it's not the case in the question as phrased. –  Joseph Wright Feb 14 '13 at 17:32
add comment

1 Answer

up vote 1 down vote accepted

In general, when pandoc finds something which looks like a latex command (i.e: the escape char \ followed by letters, and possibly several arguments in braces, such as in \emph{xxx}) it passes the command and its arguments without processing directly to the generated .tex file. When the output format is not latex related, it ignores the complete command and its arguments (e.g: in the html ouptput).

In your case \i has the structure of a tex command, but \= does not because it does not contain any letter (and apparently pandoc does not support active chars). This explains the result you got.

Possible workarounds:

  1. "Hacking" the tex output. You can define in your latex template (or even inside your pandoc document) the following command:

    \def\passthrulatex#1{#1}
    

    Then, when you use this command as part of your pandoc document, the command and its argument will be passed without changes to the resulting .tex file. So, you can for example write \passthrulatex{Mah\={a}v\={\i}ra} and get the desired output in the pdf. However, if you try to produce html this whole command (and its argumet) will dissapear in the html version, so this solution is not optimal.

  2. Using unicode. Instead of using tex accent primitives, input directly the unicode chars in the pandoc source. This is IMHO a more sensible solution, since after all pandoc source should be as independent as possible of the final format (and thus of tex). In this case you would write directly Mahāvīra in your pandoc source, and save that file with utf8 encoding.

    Pandoc will pass the unicode directly to the output, so it will work for html output, and also for pdf output if the latex template used is prepared to deal with utf8. Pandoc's default template comes with utf8 support, so it should work out of the box. You can even use pandoc to generate the intermediate tex file and then "manually" compile that file with xelatex instead of pdflatex to ensure full unicode support.

share|improve this answer
    
Thank you! Based on a previous deleted comment (yours?), I went the unicode route. A couple minutes refreshing myself on how to make the characters in vim, and a couple more minutes updating my publishing script to include --latex-engine=xelatex, and I have some beautifully accented output. Thank you so much. –  FranPeruzzi Feb 14 '13 at 16:47
    
Yes, the comment was mine, but I decided to expand it into a full answer. Glad to help. –  JLDiaz Feb 14 '13 at 16:48
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.