3

I created a markdown document in emacs. The document is in Ukrainian, so it has some cyrillic letters. I'm trying to convert it to pdf using pandoc mode. But it fails with:

markdown2pdf: ! LaTeX Error: Command \CYRP unavailable in encoding OT1.
! LaTeX Error: Command \cyrl unavailable in encoding OT1.
! LaTeX Error: Command \cyra unavailable in encoding OT1.
! LaTeX Error: Command \cyrn unavailable in encoding OT1.
! LaTeX Error: Command \CYRV unavailable in encoding OT1.
! LaTeX Error: Command \cyrs unavailable in encoding OT1.
! LaTeX Error: Command \cyrt unavailable in encoding OT1.
! LaTeX Error: Command \cyru unavailable in encoding OT1.
! LaTeX Error: Command \cyrp unavailable in encoding OT1.
! LaTeX Error: Command \CYRN unavailable in encoding OT1.
! LaTeX Error: Command \cyre unavailable in encoding OT1.
! LaTeX Error: Command \cyrv unavailable in encoding OT1.
! LaTeX Error: Command \cyre unavailable in encoding OT1.
! LaTeX Error: Command \cyrl unavailable in encoding OT1.
! LaTeX Error: Command \cyri unavailable in encoding OT1.
! LaTeX Error: Command \cyrk unavailable in encoding OT1.
! LaTeX Error: Command \cyri unavailable in encoding OT1.
! LaTeX Error: Command \cyrishrt unavailable in encoding OT1.
! LaTeX Error: Command \cyrv unavailable in encoding OT1.
! LaTeX Error: Command \cyrs unavailable in encoding OT1.
! LaTeX Error: Command \cyrt unavailable in encoding OT1.
! LaTeX Error: Command \cyru unavailable in encoding OT1.
! LaTeX Error: Command \cyrp unavailable in encoding OT1.
! LaTeX Error: Command \cyrd unavailable in encoding OT1.
! LaTeX Error: Command \cyro unavailable in encoding OT1.
! LaTeX Error: Command \CYRO unavailable in encoding OT1.
! LaTeX Error: Command \CYRO unavailable in encoding OT1.
! LaTeX Error: Command \cyrp unavailable in encoding OT1.
! LaTeX Error: Command \cyrr unavailable in encoding OT1.
! LaTeX Error: Command \cyro unavailable in encoding OT1.
! LaTeX Error: Command \cyrg unavailable in encoding OT1.
! LaTeX Error: Command \cyrr unavailable in encoding OT1.
! LaTeX Error: Command \cyra unavailable in encoding OT1.
! LaTeX Error: Command \cyrm unavailable in encoding OT1.
! LaTeX Error: Command \cyru unavailable in encoding OT1.
! LaTeX Error: Command \cyrv unavailable in encoding OT1.
! LaTeX Error: Command \cyra unavailable in encoding OT1.
! LaTeX Error: Command \cyrn unavailable in encoding OT1.
markdown2pdf: /tmp/pandoc/Thesis-outline-ukr.log: hGetContents: invalid argument (Invalid or incomplete multibyte or wide character)

How do I make it use the correct encoding? Should I specify something in my markdown document? Or is there any settings for the markdown2pdf itself?

UPD: I added this to .emacs, but it did not help:

;; set up unicode
(prefer-coding-system       'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; This from a japanese individual.  I hope it works.
(setq default-buffer-file-coding-system 'utf-8)
;; From Emacs wiki
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))

UPD2: The markdown file is here. Checksums:

gleontiev@gleontiev-laptop:~$ sum Documents/Thesis-outline-ukr.markdown 
17120     4
gleontiev@gleontiev-laptop:~$ cksum Documents/Thesis-outline-ukr.markdown 
2128209357 4078 Documents/Thesis-outline-ukr.markdown
gleontiev@gleontiev-laptop:~$ openssl dgst -sha1 Documents/Thesis-outline-ukr.markdown 
SHA1(Documents/Thesis-outline-ukr.markdown)= d36a0b4fb051e6928751eba152a5555768d1cb13

3 Answers 3

1

I believe markdown expects Unicode. perhaps you could try using recode to change the encoding from your default encoding to UTF8.


According to the Pandoc markdown2pdf manual

Input is assumed to be in the UTF–8 character encoding. If your local character encoding is not UTF–8, you should pipe input through iconv:

iconv -t utf-8 input.txt | markdown2pdf

markdown2pdf assumes that the unicode, array, fancyvrb, graphicx, and ulem packages are in latex’s search path. If these packages are not included in your latex setup, they can be obtained from http://ctan.org.

Admittedly, although I indirectly use LaTeX, I often find it's error and warning messages difficult to understand and act upon. So, although the above looks like a promising avenue, it may turn out to be a dead end.


Another possibility is to try markdown in conjunction with htmldoc instead of Pandoc's markdown2pdf - I don't know if it will solve the problem, but it may be worth trying.


I'm not getting the same checksums as you

$ wget -O Cyrillic2.markdown.txt http://paste.ideaslabs.com/download/J58n5B6cGp
11:06:08 (20.53 KB/s) - `Cyrillic2.markdown.txt' saved [4078/4078]

$ sum Cyrillic2.markdown.txt
40224     4 Cyrillic2.markdown.txt

$ cksum Cyrillic2.markdown.txt
3250703884 4078 Cyrillic2.markdown.txt

$ openssl dgst -sha1 Cyrillic2.markdown.txt
SHA1(Cyrillic2.markdown.txt)= e1d6d92b5c7a3c8673ab5dff4bfe01628b17d77a
5
  • I updated my answer. Setting default encoding in emacs and running recode UTF8 <filename> did not help.
    – George
    Nov 15, 2010 at 9:16
  • Can you provide a small sample markdown file? ideally with a checksum. Nov 15, 2010 at 9:51
  • See edited answer for checksum Nov 15, 2010 at 10:17
  • I updated my question with checksums.
    – George
    Nov 15, 2010 at 10:43
  • Sorry, I can't get it to work any better than you did. See other suggestion above. Nov 15, 2010 at 11:00
0
  1. Generate TeX from markdown using pandoc.
  2. Edit the tex file. Locate the command

    \usepackage[T1]{fontenc}
    

    and change it to

    \usepackage[T2A]{fontenc}
    
  3. Add the following command, too:

    \usepackage[ukrainian]{babel}
    
  4. Compile the tex file using pdflatex.

3
  • Can you explain how this helps? I have a document in English but I need some examples in Cyrillic, and some in Japanese, etc. Does T2A select Cyrillic specifically?
    – tripleee
    Sep 16, 2014 at 10:52
  • 1
    Yes, t2a is for Cyrillic. This answer is a bit old -- these days I'd advise using xetex, which would also solve your multilingual problem. If you take current pandoc's output and run through xelatex, it may even work without any modifications. Sep 16, 2014 at 11:35
  • Thanks for the xetex/xelatex tip, I could have been stuck in the maze for much longer.
    – tripleee
    Sep 17, 2014 at 14:33
0

A bit late in the game, here's how I solved it.

  • Use --latex-engine=xelatex for default UTF-8 everywhere.
  • Use fonts with the required glyphs.

The command line which works for me is

pandoc --latex-engine=xelatex -V mainfont:"Linux Libertine O" -V monofont="Ubuntu" -o out.pdf in.md

I have yet to discover a suitable monofont which supports Cyrillic which is actually fixed width.

1
  • Ack tip from @RomanCheplyaka which nudged me in the right direction.
    – tripleee
    Sep 17, 2014 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .