2

I am searching for the easiest way possible to allow someone (who for example may not be strong with LaTeX) to control the contents of a specific document. To give more context, I am looking to create a collection of "main" documents with the same format, composed almost exclusively of different combinations of a set of about 30 "smaller" documents (each of these are essentially sections or subsections inside of the "main" documents). An important note is that the "smaller" documents often undergo minor updates, so they are called into the "main" documents from separate files (to avoid having to change many "main" documents by hand when small changes occur).

What I have arrived at thus far is a general "main" document which contains toggles in the preamble that control which "smaller" documents appear in the "main" document. Everything is working fine at this point, where the only step for the person creating the "main" documents is to comment "%" before \toggletrue in the preamble if they don't want that specific "smaller" document in the "main" document they are making (for example below "TheFirstDocument" wouldn't appear in the "main" document). Also what I have written below isn't meant to compile of course (missing files and packages), it is just to show a general example.

My question is, is there a way to create a very friendly user interface where perhaps the person making the "main" documents could just check off boxes of which "smaller" documents they wanted to include? If this isn't possible with LaTeX itself does anyone have suggestions of the easiest thing to turn to from here to achieve that?

\documentclass{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Select Desired Documents %%%

\newtoggle{TheFirstDocument}
%\toggletrue{TheFirstDocument}

\newtoggle{TheSecondDocument}
\toggletrue{TheSecondDocument}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\iftoggle{TheFirstDocument}
{ExecuteMetaData[TheFirstDocument.tex]{tag}
}
{%nothing
}

\iftoggle{TheSecondDocument}
{ExecuteMetaData[TheSecondDocument.tex]{tag}
}
{%nothing
}

\end{document}
6
  • Perhaps this question might be helpful: Importing Parameters From a Separate File.
    – Alan Munn
    Apr 13, 2017 at 17:04
  • @AlanMunn thanks that is definitely similar to what I was doing. However, my question is different in the sense that I am not really concerned with the "parent" document becoming muddled up. I am really just wondering about the possibility of creating a checklist (like this for example: contextures.com/images/datavalidation/datavallistboxprem10.png) so that the person creating the document doesn't have to write anything in LaTex at all, they can just tick off the "smaller" documents that they desire in the main one.
    – Elijah
    Apr 13, 2017 at 18:04
  • 1
    It wouldn't be very difficult to do this with a web form.
    – Alan Munn
    Apr 13, 2017 at 18:06
  • Could you possibly elaborate on that slightly more? I'm not very experienced with LaTeX or web forms and would appreciate it.
    – Elijah
    Apr 13, 2017 at 18:19
  • On the LaTeX side of things, what are these toggles and tags doing that \input/\include (or perhaps) \includeonly don't already do?
    – jon
    Apr 13, 2017 at 20:33

1 Answer 1

2

The LaTeX half of an answer:

First, you can divide Main.tex into three files:

InitMain.tex contains the \documentcalss, some essential packages for the second file, and all the \newtoggles you need.

\documentclass{article}
\usepackage{etoolbox}

\newtoggle{TheFirstDocument}
\newtoggle{TheSecondDocument}

The second file (Main_A.tex) \inputs InitMain.tex, then contains all the \toggletrues you need and finally \inputs Main.tex

\input{InitMain}
\toggletrue{TheFirstDocument}
%\toggletrue{TheSecondDocument}
\input{Main}

And Main.tex can contain additional \usepackages and other stuff you need. And of course you conditionally input the small documents here.

% additional preamble stuff

\begin{document}

\iftoggle{TheFirstDocument}
{\input{TheFirstDocument.tex}
}
{%nothing
}

\iftoggle{TheSecondDocument}
{\input{TheSecondDocument.tex}
}
{%nothing
}

\end{document}

Then you only need to compile Main_A.tex to get the final document.

With this, the users only have to edit the small file Main_A.tex and you could have files Main_B.tex, Main_C.tex and so on with different settings.

The other half of the answer depends on the operating system, available scripting languages, skills and more. You could write a script, which reads Main_A.tex, initialises the checkboxes and finally writes a new version with added or removed % signs. For example: on Windows jscript could be used to build a GUI like the one you showed. There you could even add a button, which calls, for exapmle, latexmk (never used this) to produce the final document directly from the dialog, provided there is a LaTeX installation on the computer.

2
  • I don't think I currently have the skill to do that but I suppose it's never too late to learn. In regards to picking which language to use, would you recommend trying jscript? What you described is pretty much exactly what I am trying to do.
    – Elijah
    Apr 13, 2017 at 21:56
  • @Elijah: I mentioned jscript for two reasons: it can be used to build a dialog and it comes with Windows. The latter is a plus, because other solutions (Phyton comes to mind) require installing some software package on each PCs. But since I only did scripting with jscript so far, I can't draw comparisons.
    – Mike
    Apr 13, 2017 at 22:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .