I want to use the ModernCV template with pandoc. I have a custom .cls file, various .sty files and one .tex file that makes use of the custom class. I can convert the .tex file with pdflatex without problems, the custom class and styles are used automatically when in the same folder. When I try to convert the same file with pandoc, it fails with

Error producing PDF.
! Undefined control sequence.
l.76 \cvitem

From my understanding, pandoc doesn't automatically use .cls files, but when I run pandoc cv_7.tex -o ex.pdf -M documentclass=moderncv, it fails with

Error producing PDF.
! LaTeX Error: Option clash for package hyperref.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

l.59 \begin{document}

hyperref is only loaded once though, this is the relevant part of the modercv.cls:

% hyper links (hyperref is loaded at the end of the preamble to pass options required by loaded packages such as CJK)
  \pagenumbering{arabic}% has to be issued before loading hyperref, as to set \thepage and hence to avoid hyperref issuing a warning and setting pdfpagelabels=false
  \RequirePackage[unicode]{hyperref}% unicode is required for unicode pdf metadata
    baseurl       = http://,
    pdfborder     = 0 0 0,
    pdfpagemode   = UseNone,% do not show thumbnails or bookmarks on opening
    pdfstartpage  = 1,
    pdfcreator    = {\LaTeX{} with 'moderncv' package},
%    pdfproducer   = {\LaTeX{}},% will/should be set automatically to the correct TeX engine used
    bookmarksopen = true,
    bookmarksdepth= 2,% to show sections and subsections
    pdfauthor     = {\@firstname{}~\@familyname{}},
    pdftitle      = {\@firstname{}~\@familyname{} -- \@title{}},
    pdfsubject    = {Resum\'{e} of \@firstname{}~\@familyname{}},
    pdfkeywords   = {\@firstname{}~\@familyname{}, curriculum vit\ae{}, resum\'{e}}}}

% graphics

I think I probably have to tweak the .cls file a bit to make it work. Is there a way to include the class as is in pandoc or should I transfer the whole file to the header-includes section of the YAML header or something entirely different?

  • How do you want to use ModernCV with pandoc? I see no advantage of using pandoc here, since you'd end up using the custom commands provided by ModernCV, which would be no different than writing LaTeX in the fist place. I'd suggest, you use a pandoc solution like Markdown Resume instead. – DG' Oct 28 '19 at 19:59
  • The one you linked is quite nice, but I just like the ModernCV class and its theme options. I am generally interested in how to include such a class in pandoc and I think its advantage is that it is easier to manage and to create a template, even with custom commands. – iuvbio Oct 28 '19 at 20:22
  • other packages maybe loading hyperref implicitly? Or possibly Pandoc is doing it behind the scenes. (similarly to what arXiv is doing: tex.stackexchange.com/questions/329461/…). Oh yes, per the manual, Pandoc requires you to have hyperref available in your local TeX installation. Chances are Pandoc loads hyperref regardless of your class file. The fact your class tries to load it with [unicode] option probably causes the option clash. – Willie Wong Oct 28 '19 at 21:04
  • I think you were right, when I skip loading hyperref, that error doesn't come up anymore, but it still fails to build the file complaining about undefined control sequence.. – iuvbio Oct 29 '19 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.