0

I would like to be able to "turn on/off" certain sections of my documents, depending on a command line declaration.

I am converting a large group of policy documents that are for both internal and external use, via Pandoc, to PDF, using a LaTeX template, and Pandoc is using pdfTeX. I also have a PowerShell script that converts them recursively.

gci -r -i *.md | foreach{$pdf=$_.directoryname+"\"+$_.basename+".pdf"; pandoc -f markdown --template template.latex -V geometry:margin=1.5cm -V fontfamily:lato -V fontfamilyoptions:default -V fontfamilyoptions:defaultsans -s $_.name -o $pdf}

External versions don't need the document details section, which is the first page after the table of contents. I could probably remove the third page, but there are some documents with long ToC's, and some without, besides which, it doesn't strike me as a an elegant solution.

My typical document looks something like this (YAML and content reduced for brevity):

---
title: "A policy"
documentdetails: True/false % I could add something here for the default?
...

Table of contents:

\documentdetailstart % A tag looking like this for instance

# Document Details

#### Document Details

| Description | Status/Version | Reference Code | Control |
| --- |---|---|---|
|A Policy | Final / 1.0 | LaTeX | All |

\documentdetailend % A tag looking like this for instance

Begin Document

How can I add some kind of wrapping to the markdown of each policy, that is dealt with in the template perhaps, so that I can add something like the below on the command line to automatically omit/include the contents of the tag.

-V Documentdetails:True

Thanks in advance for any assistance you can provide!

0

You could have an

\iftrue
Document details
\fi

and tell your powershell script to replace iftrue with iffalse and compile a new copy.

Edit: If you surround all the internal only stuff with \begininternal and \endinternal as below, then you can toggle between whether the document is for an internal or an external copy of the pdf by replacing iffalse with iftrue on the second line. Then you just need to get your script to say "if external, replace iffalse with iftrue and compile" or somesuch.

\documentclass{article}
\let\begininternal\iffalse
\let\endinternal\fi

\begin{document}
Stuff everyone gets

\begininternal
Internal  only stuff
\endinternal

More stuff everyone gets

\begininternal
More internal only stuff
\endinternal

The end.
\end{document}

enter image description here

3
  • Hi Fintan, thanks for your reply, I'm quite new to LaTeX and I was wondering if you could provide a little more detail about how I would go about this. Each of the documents has a # Document Details heading, so are you saying I should tell it to exclude that specific heading? Or do I need to amend the template&markdown in some way to allow this?
    – JV53
    Dec 5 '19 at 11:50
  • Apologies - I've edited my response and elaborated a little. Hopefully that makes things clearer. If I've misunderstood what you're trying to do, please let me know.
    – Fintan
    Dec 5 '19 at 12:36
  • That's fantastic, It was just the \let\begininternal\iffalse part that I didn't know how to add. This works perfectly. I guess I could just have two templates, one with true, and one with false. I imagine the -V in powershell bit is the 'proper' way, but probably for a separate question/further research on my part - unless you have any ideas? Many thanks for your help though, I'll mark this as answered!
    – JV53
    Dec 5 '19 at 15:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.