I've been trying to use Pandoc to convert some Markdown into a PDF file. This is a sample that Pandoc will not convert for me:
# Header!
## Sub Header
themselves derived respectively from the Greek ?ναρχ?α i.e. 'anarchy'
That's just something I grabbed from the top of the wikipedia database dump. Pandoc doesn't like that at all. This is the error message it gives me:
pandoc: Error producing PDF from TeX source.
! Package inputenc Error: Unicode char u8:? not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.53 ...es derived respectively from the Greek ?
Is there a command switch I can give it to get around this? I tried following the advice to do something like this, but it failed:
iconv -t utf-8 test.md | pandoc -o test.pdf
Update Before following John's advice below, see this.
Update 2 This is the command that ultimately got it working. Hopefully this will help someone:
pandoc test2.md -o test2.pdf --latex-engine=xelatex --template=my.latex --variable mainfont="DejaVu Serif" --variable sansfont=Arial
And this is the contents of my.latex
:
documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{amssymb,amsmath}
usepackage{ifxetex,ifluatex}
usepackage{fixltx2e} % provides extsubscript
% use microtype if available
IfFileExists{microtype.sty}{usepackage{microtype}}{}
% use upquote if available, for straight quotes in verbatim environments
IfFileExists{upquote.sty}{usepackage{upquote}}{}
ifnum 0ifxetex 1fiifluatex 1fi=0 % if pdftex
usepackage[utf]{inputenc}
usepackage{ucs}
$if(euro)$
usepackage{eurosym}
$endif$
else % if luatex or xelatex
usepackage{fontspec}
ifxetex
usepackage{xltxtra,xunicode}
fi
defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
setromanfont{TeX Gyre Pagella}
ewcommand{euro}{€}
$if(mainfont)$
setmainfont{$mainfont$}
$endif$
$if(sansfont)$
setsansfont{$sansfont$}
$endif$
$if(monofont)$
setmonofont{$monofont$}
$endif$
$if(mathfont)$
setmathfont{$mathfont$}
$endif$
fi
$if(geometry)$
usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
$if(natbib)$
usepackage{natbib}
ibliographystyle{plainnat}
$endif$
$if(biblatex)$
usepackage{biblatex}
$if(biblio-files)$
ibliography{$biblio-files$}
$endif$
$endif$
$if(listings)$
usepackage{listings}
$endif$
$if(lhs)$
lstnewenvironment{code}{lstset{language=Haskell,basicstyle=smalltfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
usepackage{fancyvrb}
$endif$
$if(tables)$
usepackage{longtable}
$endif$
$if(graphics)$
usepackage{graphicx}
% We will generate all images so they have a width maxwidth. This means
% that they will get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
makeatletter
defmaxwidth{ifdimGin@nat@width>linewidthlinewidth
elseGin@nat@widthfi}
makeatother
letOldincludegraphicsincludegraphics
enewcommand{includegraphics}[1]{Oldincludegraphics[width=maxwidth]{#1}}
$endif$
ifxetex
usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex]{hyperref}
else
usepackage[unicode=true]{hyperref}
fi
hypersetup{breaklinks=true,
bookmarks=true,
pdfauthor={$author-meta$},
pdftitle={$title-meta$},
colorlinks=true,
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
pdfborder={0 0 0}}
urlstyle{same} % don't use monospace font for urls
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
enewcommand{href}[2]{#2footnote{url{#1}}}
$endif$
$if(strikeout)$
usepackage[normalem]{ulem}
% avoid problems with sout in headers with hyperref:
pdfstringdefDisableCommands{
enewcommand{sout}{}}
$endif$
setlength{parindent}{0pt}
setlength{parskip}{6pt plus 2pt minus 1pt}
setlength{emergencystretch}{3em} % prevent overfull lines
$if(numbersections)$
$else$
setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(lang)$
ifxetex
usepackage{polyglossia}
setmainlanguage{$mainlang$}
else
usepackage[$lang$]{babel}
fi
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$if(title)$
itle{$title$}
$endif$
author{$for(author)$$author$$sep$ and $endfor$}
date{$date$}
egin{document}
$if(title)$
maketitle
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(toc)$
{
hypersetup{linkcolor=black}
setcounter{tocdepth}{$toc-depth$}
ableofcontents
}
$endif$
$body$
$if(natbib)$
$if(biblio-files)$
$if(biblio-title)$
$if(book-class)$
enewcommandibname{$biblio-title$}
$else$
enewcommand
efname{$biblio-title$}
$endif$
$endif$
ibliography{$biblio-files$}
$endif$
$endif$
$if(biblatex)$
printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
$include-after$
$endfor$
end{document}
See Question&Answers more detail:
os