I have a document that I sometimes want to print as one single document, and other times I want to print it as smaller groups of pages. I would like to automate the process. I'm using TeXmaker with LuaLaTeX on a Windows 10 machine.
I'm unclear what arguments I need to pass to the \ShellEscape command. I've read several of the other posts on this but they are mostly from about 8-9 years ago and I cannot get the code to work. I cannot tell if there has been a change to TeX (or Windows) such that the solutions in these older posts no longer work.
Here is my MWE (which doesn't work).
% !TEX TS-program = lualatex
% !TEX encoding = UTF-8 Unicode
\documentclass[a4paper,12pt]{article}
\usepackage{shellesc} %for creating multiple output files.
\usepackage{etoolbox} %for use with the toggles function
\newtoggle{individualpages}
\togglefalse{individualpages}
\begin{document}
Test page 1.
\iftoggle{individualpages}{%
And this too. %testing code just to make sure the toggle is working.
\ShellEscape{lualatex --jobname="file1.pdf"}
}{}
\newpage
Test page 2.
\iftoggle{individualpages}{%
Dont forget me!
\ShellEscape{lualatex --jobname="file2.pdf"}
}{}
\end{document}
Ideally I would turn the toggle to false and it would compile a .pdf using the name of my .tex document of all pages. However, when I turn the toggle to true, it would create 2 separate .pdf files named "file1.pdf" and "file2.pdf", each one page and containing there respective texts. Is this even possible?
pdflatex
and if so what arguments do you pass to it to compile? Look into your editor-settings to find it out. One common string would bepdflatex -synctex=1 -interaction=nonstopmode -file-line-error file.tex
, but could be very different, too. Usually you need to 'allow' shell escape to function when you call your compiler. So you have to pass e.g the--enable-write18
option. But that may also depend on your LaTeX distribution. For MikTex, for example see here: tex.stackexchange.com/questions/37489/…\ShellEscape{lualatex --jobname="file1" \jobname}
. But you will also need code which selects the content. Do you really want to get specific pages, or do you want to select some part of the content, like e.g. a section?