{"id":1594,"date":"2016-06-07T21:34:02","date_gmt":"2016-06-07T20:34:02","guid":{"rendered":"http:\/\/slave27.local\/kb\/?p=1594"},"modified":"2016-06-07T21:34:02","modified_gmt":"2016-06-07T20:34:02","slug":"pandoc-commands","status":"publish","type":"post","link":"https:\/\/andy.teknostatik.co.uk\/kb\/2016\/06\/07\/pandoc-commands\/","title":{"rendered":"Pandoc commands"},"content":{"rendered":"<p>I wrote about <a href=\"http:\/\/pandoc.org\/\">Pandoc<\/a> last year, but I&#8217;m using it more and more and I&#8217;ve found myself editing the original post a fair few times. This is the updated 2016 version that gathers together useful commands I&#8217;ve learned so far.<\/p>\n<p>Last year I found myself needing to do a lot of document conversion, and maintaining documentation that needs to be available in a variety of formats (HTML, Word documents, Markdown and PDF). My tool of choice for this sort of thing is Pandoc, which is available for Windows, Mac OS X and Linux, although most of my usage so far has been on Linux and Mac OS X (it&#8217;s a command line package that can output to Dropbox, so it doesn&#8217;t matter where it runs really).<\/p>\n<p>There are <a href=\"http:\/\/pandoc.org\/installing.html\">instructions for installing Pandoc<\/a> on quite a few platforms. I&#8217;ve found that following these is generally enough, although it&#8217;s worth installing <a href=\"https:\/\/github.com\/jgm\/pandoc\/releases\/latest\">the latest version of the .deb packages<\/a> rather than the one in the repositories.<\/p>\n<p>On Debian\/Ubuntu I also add the <code>texlive-latex-extra<\/code> package, but that\u2019s largely because it gives me a specific Beamer theme I like to use.<\/p>\n<p>If you\u2019re using Pandoc on Mac OS X there is one more command you\u2019ll need to issue prior to the first time you want to create a PDF file:<\/p>\n<pre><code>sudo ln -s \/Library\/TeX\/texbin\/pdflatex \/usr\/local\/bin\/\n<\/code><\/pre>\n<p>This will ensure Pandoc knows where to find pdflatex. If this step isn\u2019t followed then you\u2019ll likely get an error message along the lines of <code>pandoc: pdflatex not found<\/code>. pdflatex is needed for pdf output.<\/p>\n<p>Pandoc works for me because I write everything in markdown, and Pandoc is great at taking markdown and converting it into almost anything else. It&#8217;s also good if you need to create a PDF, a Word document and a slide show from the same document. The syntax is fairly simple for most document types:<\/p>\n<p>For example:<\/p>\n<pre><code>pandoc input.md -s -o output.docx\npandoc input.md -s -o output.html\npandoc input.md -s -o output.epub\n<\/code><\/pre>\n<p>Conversion to PDF works the same, although I&#8217;m not a fan of wide margins, so I tweak it slightly:<\/p>\n<pre><code>pandoc -V geometry:margin=1in input.md -s -o output.pdf\n<\/code><\/pre>\n<p>For a Beamer slide show you\u2019ll need something like:<\/p>\n<pre><code>pandoc -t beamer input.md -V theme:metropolis -o output.pdf\n<\/code><\/pre>\n<p>Pandoc does a lot more, but the documentation is great, and the commands above should be enough to get you started. If you want to try out the functionality in a web browser then <a href=\"http:\/\/pandoc.org\/try\/\">http:\/\/pandoc.org\/try\/<\/a> should be able to handle most types of conversions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wrote about Pandoc last year, but I&#8217;m using it more and more and I&#8217;ve found myself editing the original post a fair few times. This is the updated 2016 version that gathers together useful commands I&#8217;ve learned so far. Last year I found myself needing to do a lot of document conversion, and maintaining &#8230; <a title=\"Pandoc commands\" class=\"read-more\" href=\"https:\/\/andy.teknostatik.co.uk\/kb\/2016\/06\/07\/pandoc-commands\/\" aria-label=\"Read more about Pandoc commands\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","_share_on_mastodon":"0"},"categories":[3,5,6,8],"tags":[],"class_list":["post-1594","post","type-post","status-publish","format-standard","hentry","category-debian","category-linux","category-mac-os-x","category-ubuntu"],"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts\/1594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/comments?post=1594"}],"version-history":[{"count":0,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts\/1594\/revisions"}],"wp:attachment":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/media?parent=1594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/categories?post=1594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/tags?post=1594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}