| 1 |
%! HV lualatex |
| 2 |
%! HV biber |
| 3 |
%! HV xindex |
| 4 |
%! HV lualatex |
| 5 |
%! HV lualatex |
| 6 |
|
| 7 |
%% $Id: runtexfile-doc.tex 7 2025-10-08 07:34:58Z herbert $ |
| 8 |
% |
| 9 |
\listfiles\setcounter{errorcontextlines}{100} |
| 10 |
\documentclass[paper=a4,fontsize=11pt,DIV=14,parskip=half-, |
| 11 |
captions=tableabove,twoside=on]{scrartcl} |
| 12 |
\usepackage{fontspec} |
| 13 |
|
| 14 |
%\usepackage{libertinus-otf} |
| 15 |
\setmainfont{AccanthisADFStdNo3}[ |
| 16 |
UprightFont =*-Regular, |
| 17 |
BoldFont =*-Bold, |
| 18 |
ItalicFont =*-Italic, |
| 19 |
BoldItalicFont=*-BoldItalic, |
| 20 |
RawFeature = -rlig, |
| 21 |
] |
| 22 |
\setsansfont{GilliusADF}[ |
| 23 |
UprightFont =*-Regular, |
| 24 |
BoldFont =*-Bold, |
| 25 |
ItalicFont =*-Italic, |
| 26 |
BoldItalicFont=*-BoldItalic, |
| 27 |
RawFeature = -rlig, |
| 28 |
] |
| 29 |
|
| 30 |
\usepackage{juliamono} |
| 31 |
\usepackage[english]{babel} |
| 32 |
\usepackage{scrlayer-scrpage} |
| 33 |
\automark[section]{section} |
| 34 |
\automark*[subsection]{} |
| 35 |
\pagestyle{scrheadings} |
| 36 |
|
| 37 |
{\catcode`\%=12 |
| 38 |
\gdef\perCent{%} |
| 39 |
\gdef\DoubleperCent{%%} |
| 40 |
} |
| 41 |
|
| 42 |
\usepackage{xcolor,fancyvrb,varioref,awesomebox} |
| 43 |
\usepackage{xltabular} |
| 44 |
\usepackage{hvlogos} % for Wikipedia W |
| 45 |
\usepackage{listings} |
| 46 |
\usepackage{hvextern} |
| 47 |
\lstset{basicstyle=\ttfamily\small,language=[LaTeX]TeX} |
| 48 |
\usepackage{ragged2e} |
| 49 |
\usepackage[makeidx]{hvindex} |
| 50 |
|
| 51 |
\def\Lfile#1{\texttt{#1}\index{#1 file@\texttt{#1} file}} |
| 52 |
\def\Lext#1{\texttt{.#1}\index{#1 file extension@\texttt{.#1} file extension}} |
| 53 |
\def\Lcs#1{\texttt{\textbackslash#1}\index{#1@\texttt{\textbackslash#1}}} |
| 54 |
\def\Lenv#1{\texttt{#1}\index{#1 environment@\texttt{#1} environment}} |
| 55 |
\def\Lpack#1{\texttt{#1}\index{#1 package@\texttt{#1} package}} |
| 56 |
\def\Lprog#1{\texttt{#1}\index{#1 program@\texttt{#1} program}} |
| 57 |
\def\Loption#1{\texttt{#1}\index{#1@\texttt{#1} package option}} |
| 58 |
\def\Largb#1{\emph{\{#1\}}} |
| 59 |
|
| 60 |
\usepackage[style=authoryear]{biblatex} |
| 61 |
\addbibresource[location=remote]{https://www.ctan.org/tex-archive/biblio/ctan-bibdata/ctan.bib} |
| 62 |
|
| 63 |
\raggedbottom |
| 64 |
\usepackage{url} |
| 65 |
\usepackage[colorlinks,linktocpage]{hyperref} |
| 66 |
|
| 67 |
\usepackage{minted-code} |
| 68 |
\usepackage{fancyref} |
| 69 |
|
| 70 |
\makeatletter% from: doc.sty |
| 71 |
\newcommand*\GetFileInfo[1]{% |
| 72 |
\def\filename{#1}% |
| 73 |
\def\@tempb##1 ##2 ##3\relax##4\relax{% |
| 74 |
\def\filedate{##1}% |
| 75 |
\def\fileversion{##2}% |
| 76 |
\def\fileinfo{##3}}% |
| 77 |
\edef\@tempa{\csname ver@#1\endcsname}% |
| 78 |
\expandafter\@tempb\@tempa\relax? ? \relax\relax} |
| 79 |
\makeatother |
| 80 |
|
| 81 |
\usepackage{xspace} |
| 82 |
|
| 83 |
\newcommand\rD{\texttt{runtexfile}\xspace} |
| 84 |
|
| 85 |
\title{Script \texttt{runtexfile} \\--\\ \normalsize v. 0.06 (\today)} |
| 86 |
\author{\shortstack{Herbert Voß\\\small \href{mailto:[email protected]}{[email protected]}}} |
| 87 |
\date{} |
| 88 |
\begin{document} |
| 89 |
\maketitle |
| 90 |
\thispagestyle{empty} |
| 91 |
%\enlargethispage{1cm} |
| 92 |
\tableofcontents |
| 93 |
|
| 94 |
\begin{noteblock} |
| 95 |
\raggedright |
| 96 |
Thanks to: \\ |
| 97 |
Rolf Niepraschk |
| 98 |
\end{noteblock} |
| 99 |
\clearpage |
| 100 |
|
| 101 |
\section{Introduction} |
| 102 |
The \Index{Lua} program \rD parses an \AllTeX-document for lines |
| 103 |
starting with \verb|%! HV |. The «HV» has no meaning, it should only |
| 104 |
be a significant marker for the command lines. |
| 105 |
Such lines can define commands which will be |
| 106 |
executed by \rD. These lines must be at the beginning of the document. |
| 107 |
Only empty lines before will be ignored. \rD will stop parsing for commands |
| 108 |
if a line without a preceeding \verb|%! HV | is found. If there is no such line, |
| 109 |
it runs the document by default with \Lprog{lualatex}. |
| 110 |
|
| 111 |
|
| 112 |
\subsection{Syntax} |
| 113 |
|
| 114 |
The \Index{syntax} is \verb|runtexfile [...] <file>| where \verb|[...]| are optional \Index{argument}s, either in short or |
| 115 |
long form which, of course, can be mixed: |
| 116 |
|
| 117 |
\begin{verbatim} |
| 118 |
runtexfile [-h,--help] [-v,--verbose] [-V,--version ] main-filename |
| 119 |
\end{verbatim} |
| 120 |
|
| 121 |
Every executed command gets an own \Index{logfile} \verb|runtexfile-?.log| in which |
| 122 |
the question mark is the number of the corresponding command line in |
| 123 |
the document. This allows to locate any problem in the several external |
| 124 |
runs. |
| 125 |
With the option -v (\Index{verbose}) a short logfile which lists more or less only the important steps |
| 126 |
from within the script is \Lfile{runtexfile.log}. |
| 127 |
|
| 128 |
All \LaTeX\ commands are startet with the option\index{nonstopmode|texttt} |
| 129 |
|
| 130 |
\verb|--interaction=nonstopmode| |
| 131 |
|
| 132 |
The supported \AllTeX-commands |
| 133 |
are |
| 134 |
|
| 135 |
\begin{verbatim} |
| 136 |
local commands = {"lualatex", "luatex", "luahbtex", "latex", "pdflatex", |
| 137 |
"xelatex", "xetex" } |
| 138 |
\end{verbatim} |
| 139 |
|
| 140 |
This is not really of interest, because it is only needed for the decision |
| 141 |
to use the option \verb|--interaction=nonstopmode| or not. It is only valid for |
| 142 |
any run depending to a \AllTeX-program. |
| 143 |
The optional \Index{filename} \verb|<file>| must always be used if the current command expects |
| 144 |
another filename (see example for multiple index files). See also section~\vref{mainfile} |
| 145 |
for \Index{online-compiler}s where you often do not know the main filename. |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
\subsection{\TeX studio} |
| 150 |
|
| 151 |
For \TeX studio use as default compiler \Lfile{latexmk} and simply replace the |
| 152 |
name by \Lfile{runtexfile} (see last line in the second image): |
| 153 |
|
| 154 |
\includegraphics[width=\linewidth]{images/compiler} |
| 155 |
|
| 156 |
|
| 157 |
\begin{center} |
| 158 |
\includegraphics[width=\linewidth]{images/latexmk} |
| 159 |
\end{center} |
| 160 |
|
| 161 |
|
| 162 |
\section{examples} |
| 163 |
|
| 164 |
\subsection{This document} |
| 165 |
|
| 166 |
The header looks like |
| 167 |
|
| 168 |
\begin{codeblock}[minted language=latex, title=Command lines for this document] |
| 169 |
%! HV lualatex |
| 170 |
%! HV biber |
| 171 |
%! HV xindex |
| 172 |
%! HV lualatex |
| 173 |
%! HV lualatex |
| 174 |
|
| 175 |
%% $Id: runtexfile-doc.tex 7 2025-10-08 07:34:58Z herbert $ |
| 176 |
% |
| 177 |
\listfiles\setcounter{errorcontextlines}{100} |
| 178 |
\documentclass[paper=a4,fontsize=11pt,DIV=14,parskip=half-, |
| 179 |
captions=tableabove,twoside=on]{scrartcl} |
| 180 |
\usepackage{fontspec} |
| 181 |
[...] |
| 182 |
\end{codeblock} |
| 183 |
|
| 184 |
In this case no extra filename is needed, running \verb|runtexfile runtexfile-doc| |
| 185 |
is sufficiant. More complex is the header of example \verb|test2|: |
| 186 |
|
| 187 |
|
| 188 |
\subsection{Document test} |
| 189 |
This document uses package \Lpack{imakeidx} which itself |
| 190 |
runs the index commands.~\parencite{ctan-imakeidx} |
| 191 |
|
| 192 |
\begin{codeblock}[language=latex,title=Example \texttt{test}] |
| 193 |
%! HV lualatex --shell-escape |
| 194 |
%! HV biber <test.aux> |
| 195 |
%! HV lualatex --shell-escape |
| 196 |
%! HV lualatex --shell-escape |
| 197 |
|
| 198 |
%% The index files are run by imakeidx |
| 199 |
[...] |
| 200 |
\end{codeblock} |
| 201 |
|
| 202 |
The filename for \Lfile{biber} is not really needed, because it also |
| 203 |
works with the main filename. |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
\subsection{Document test2} |
| 208 |
|
| 209 |
A more complex example: |
| 210 |
|
| 211 |
|
| 212 |
\begin{codeblock}[language=latex,title=Example \texttt{test2}] |
| 213 |
%! HV lualatex --shell-escape |
| 214 |
%! HV biber |
| 215 |
%! HV lualatex --shell-escape |
| 216 |
%! HV xindex |
| 217 |
%! HV xindex --config DIN2 -l DE -o test2.vwd <test2.vwx> |
| 218 |
%! HV xindex --config DIN2 -l DE -o test2.dbd <test2.dbx> |
| 219 |
%! HV lualatex --shell-escape |
| 220 |
%! HV lualatex --shell-escape |
| 221 |
\end{codeblock} |
| 222 |
|
| 223 |
|
| 224 |
There is an optional argument for \Lprog{lualatex} and options with |
| 225 |
another filename for two of the three \Lprog{xindex} runs.~\parencite{ctan-xindex} |
| 226 |
|
| 227 |
\subsection{Document test3 -- for Online-Compiler}\label{mainfile} |
| 228 |
|
| 229 |
Most applications do not need the original filename, but in an extended |
| 230 |
version, like \LaTeX\ together with \Lprog{asymptote} it is |
| 231 |
different.~\parencite{ctan-asymptote} Sometimes you do not know the original |
| 232 |
filename, for example when working with an \Index{online-compiler}. |
| 233 |
In such a case one can use |
| 234 |
the \Index{placeholder} \verb|!!file!!| which will be later replaced |
| 235 |
by the original \TeX-filename which is used by the first command line.. |
| 236 |
|
| 237 |
\begin{codeblock}[language=latex,title=Example \texttt{test3} (Asymptote)] |
| 238 |
%! HV lualatex --shell-escape |
| 239 |
%! HV asy <!!file!!-*asy> |
| 240 |
%! HV lualatex --shell-escape |
| 241 |
\end{codeblock} |
| 242 |
|
| 243 |
Remember that this makes no real sense here, because you know the main file |
| 244 |
name. |
| 245 |
|
| 246 |
\printbibliography |
| 247 |
|
| 248 |
\printindex |
| 249 |
|
| 250 |
\end{document} |