{"id":6549,"date":"2019-04-23T02:35:33","date_gmt":"2019-04-23T01:35:33","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=6549"},"modified":"2019-04-23T02:35:33","modified_gmt":"2019-04-23T01:35:33","slug":"adding-extra-latex-packages-to-pandoc","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=6549","title":{"rendered":"Adding extra Latex packages to Pandoc"},"content":{"rendered":"<p>My preferred workflow for writing technical documents these days is to write in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Markdown\">Markdown<\/a>\u00a0(Or <a href=\"https:\/\/jupyter.org\/\">Jupyter Notebooks<\/a>) and then use <a href=\"https:\/\/pandoc.org\/MANUAL.html\">Pandoc<\/a> to convert to PDF, Microsoft Word or whatever format is required by the end client.<\/p>\n<p>While working with a markdown file recently, the pandoc conversion to PDF failed with the following error message<\/p>\n<pre>! Undefined control sequence.\r\nl.117 \\[ \\coloneqq\r\n<\/pre>\n<p>This happens because Pandoc first converts the Markdown file to LaTeX which then gets compiled to PDF and the command <strong>\\coloneqq<\/strong> isn&#8217;t included in any of the LaTeX packages that Pandoc uses by default.<\/p>\n<p>The coloneqq command is in the <a href=\"https:\/\/ctan.org\/pkg\/mathtools?lang=en\">mathtools package<\/a>\u00a0which, on Ubuntu, can be installed using<\/p>\n<pre>apt-get install texlive-latex-recommended\r\n<\/pre>\n<p>Once we have the package installed, we need to tell Pandoc to make use of it. The way I did this was to create a Pandoc metadata file that contained the following<\/p>\n<pre>---\r\nheader-includes: |\r\n            \\usepackage{mathtools}\r\n---\r\n<\/pre>\n<p>I called this file <strong>pandoc_latex.yml<\/strong> and passed it to Pandoc as follows<\/p>\n<pre>pandoc --metadata-file=.\/pandoc_latex.yml .\/input.md -o output.pdf\r\n<\/pre>\n<p>On one system I tried this on, I received the following error message<\/p>\n<pre>pandoc: unrecognized option `--metadata-file=.\/pandoc_latex.yml'\r\n<\/pre>\n<p>which suggests that the <strong>&#8211;metadata-file option<\/strong> is a relatively recent addition to Pandoc. I have no idea when this option was added but if this happens to you, you could try installing the latest version from\u00a0<a href=\"https:\/\/github.com\/jgm\/pandoc\/\">https:\/\/github.com\/jgm\/pandoc\/<\/a><\/p>\n<p>I used 2.7.1.1 and it was fine so I guess anything later than this should also be OK.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My preferred workflow for writing technical documents these days is to write in Markdown\u00a0(Or Jupyter Notebooks) and then use Pandoc to convert to PDF, Microsoft Word or whatever format is required by the end client. While working with a markdown file recently, the pandoc conversion to PDF failed with the following error message ! Undefined [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[],"class_list":["post-6549","post","type-post","status-publish","format-standard","hentry","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-1HD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/6549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6549"}],"version-history":[{"count":3,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/6549\/revisions"}],"predecessor-version":[{"id":6569,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/6549\/revisions\/6569"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}