| 1 |
%% $Id: hvextern.tex 1097 2025-05-14 07:41:01Z herbert $ |
| 2 |
\DocumentMetadata{}% for lualatex and pstricks |
| 3 |
\documentclass[english,paper=a4,twoside,usegeometry]{scrartcl} |
| 4 |
\usepackage{babel} |
| 5 |
\usepackage{libertinus} |
| 6 |
\usepackage{juliamono}% For the mono font |
| 7 |
%\setmonofont[Scale=MatchLowercase,FakeStretch=0.88]{AnonymousPro} |
| 8 |
\newfontfamily\NotoSansMono[Ligatures=TeX,Scale=MatchLowercase, |
| 9 |
FakeStretch=0.90,Ligatures=ResetAll%,RawFeature=-tlig |
| 10 |
]{Noto Sans Mono} |
| 11 |
\newfontfamily\CodeTwo{CODE2000}[Scale=MatchLowercase] |
| 12 |
|
| 13 |
\usepackage[includeheadfoot,bmargin=1cm,tmargin=5mm,textwidth=16cm]{geometry} |
| 14 |
|
| 15 |
\usepackage{iftex} |
| 16 |
|
| 17 |
\usepackage[automark]{scrlayer-scrpage} |
| 18 |
\pagestyle{scrheadings} |
| 19 |
\usepackage{hvlogos} |
| 20 |
\usepackage[checkCode]{hvextern} |
| 21 |
\usepackage{hvindex} |
| 22 |
\usepackage{hvdoctools} |
| 23 |
\usepackage{listings} |
| 24 |
\lstset{basicstyle=\ttfamily\small,language=[LaTeX]TeX,breaklines} |
| 25 |
\usepackage{xcolor,xspace,varioref} |
| 26 |
\usepackage{hyperref} |
| 27 |
|
| 28 |
\def\Python{\textsf{Python}\xspace} |
| 29 |
\def\Perl{\textsf{Perl}\xspace} |
| 30 |
\def\Lua{\textsf{Lua}\xspace} |
| 31 |
\def\Java{\textsf{Java}\xspace} |
| 32 |
|
| 33 |
|
| 34 |
\raggedbottom |
| 35 |
|
| 36 |
|
| 37 |
\begin{document} |
| 38 |
\title{Writing, running and including the output of external documents |
| 39 |
from within a main\newline \LaTeX\ document~--v. \hvexternFileversion} |
| 40 |
\author{Herbert Voß \url{[email protected]}\thanks{Thanks to Karl Berry; Denis Bitouzé; |
| 41 |
Werner Lemberg; Rolf Niepraschk}} |
| 42 |
\maketitle |
| 43 |
\tableofcontents |
| 44 |
|
| 45 |
\newpage |
| 46 |
|
| 47 |
\setkeys{hv}{moveToExampleDir,ExampleDir=Exa,showFilename,verbose,force=true} |
| 48 |
|
| 49 |
|
| 50 |
%\clearpage |
| 51 |
|
| 52 |
\section{Loading the package} |
| 53 |
|
| 54 |
\begin{verbatim} |
| 55 |
\usepackage[Option]{hvextern} |
| 56 |
\end{verbatim} |
| 57 |
|
| 58 |
There exists only one option \Loption{checkCode} which is valid |
| 59 |
for all \TeX-compiler. In this case an already existing external file will only be compiled, if the |
| 60 |
external code changed. This doesn't depends on the setting of the option \Lkeyword{force}. |
| 61 |
\Loption{checkCode} can speed up the compilation time. |
| 62 |
|
| 63 |
\section{Syntax} |
| 64 |
|
| 65 |
\addtocontents{toc}{\protect\enlargethispage{2ex}} |
| 66 |
|
| 67 |
\begin{sloppypar} |
| 68 |
This package allows to write external \MP, \TeX, \ConTeXt, \LaTeX, \LuaTeX, \LuaLaTeX, \XeTeX, \XeLaTeX, |
| 69 |
\Index{Lua}, \Index{Perl}, \Index{Java}, \Index{Python}, and /or \Index{R} |
| 70 |
source code, which will then be run via \texttt{shell escape} to create a PDF or text output to include |
| 71 |
it into the main \LaTeX\ document. The values for the |
| 72 |
optional argument \Lkeyword{compiler} must be the real prgram name on the the local system, e.g. for Windows: |
| 73 |
mpost, tex, context.exe, latex.exe, luatex.exe, lualatex.exe, xetex.exe, xelatex.exe, |
| 74 |
lua.exe, perl.exe, java.exe, pathon.exe, and /or Rscript.exe. |
| 75 |
\end{sloppypar} |
| 76 |
|
| 77 |
|
| 78 |
There is only one environment and one command: |
| 79 |
|
| 80 |
\begin{verbatim} |
| 81 |
\begin{externalDocument}[<options>]{<external filename without extension>} |
| 82 |
... |
| 83 |
source code |
| 84 |
... |
| 85 |
\end{externalDocument} |
| 86 |
|
| 87 |
\runExtCmd[<options>] |
| 88 |
{<command with arguments>} |
| 89 |
{<external filename without extension>} |
| 90 |
\end{verbatim} |
| 91 |
|
| 92 |
The very first compilation run of the main document must be done |
| 93 |
with the \Loption{-shell-escape} command-line option, otherwise it won't |
| 94 |
work. Follow-up runs, for example, to resolve references, should |
| 95 |
usually be done without \Loption{-shell-escape}. |
| 96 |
The currently used filename for the example is saved in the macro \Lcs{hvExternFilename}. |
| 97 |
|
| 98 |
\begin{verbatim} |
| 99 |
lualatex --shell-escape <file> |
| 100 |
\end{verbatim} |
| 101 |
|
| 102 |
The purpose for this package is to show the output of documents which have to be compiled with |
| 103 |
a different preamble or a different engine or a complete different system, but integrating the output |
| 104 |
automatically in the main document.. |
| 105 |
|
| 106 |
\bigskip |
| 107 |
\noindent |
| 108 |
\fbox{\begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax} |
| 109 |
\emph{All} examples in this document are created on-the-fly while running this \LaTeX\ document |
| 110 |
with \texttt{lualatex} with the \texttt{-\kern1pt-shell-escape} option. |
| 111 |
\end{minipage}} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
\section{First examples} |
| 116 |
\subsection{Without showing the code} |
| 117 |
|
| 118 |
This document was run with \LuaLaTeX. Suppose you want to insert the output of a document |
| 119 |
which needs for several reasons a \XeLaTeX\ run. Instead of created and running a document |
| 120 |
outside of the main document and then to insert the output |
| 121 |
we can do this from within this \LuaLaTeX\ document itself. The external document is compiled |
| 122 |
with \XeLaTeX\ and the output is insert as pdf image: |
| 123 |
\begin{externalDocument}[% |
| 124 |
compiler=xelatex, inline, runs=2, grfOptions={height=8pt},% |
| 125 |
crop, cropmargin=0, cleanup, docType=latex,vshift=-1pt]{voss} |
| 126 |
\documentclass{ctexart} |
| 127 |
\pagestyle{empty} |
| 128 |
\begin{document} |
| 129 |
美好的一天. |
| 130 |
\end{document} |
| 131 |
\end{externalDocument} |
| 132 |
% |
| 133 |
The current filename of the above example is \hvExternFilename\ and for the source |
| 134 |
see page \pageref{inline-exa}. |
| 135 |
|
| 136 |
Let's show another example which needs a \pdfLaTeX\ run. The \Index{source} code |
| 137 |
itself is also not |
| 138 |
shown by the environment \Lenv{externalDocument}. |
| 139 |
|
| 140 |
|
| 141 |
\begin{minipage}{.59\linewidth} |
| 142 |
\begin{lstlisting} |
| 143 |
\begin{externalDocument}[ |
| 144 |
compiler=pdflatex,cleanup]{voss} |
| 145 |
\documentclass{standalone} |
| 146 |
%StartVisiblePreamble |
| 147 |
\usepackage{fontenc} |
| 148 |
\usepackage{libertinus} |
| 149 |
\usepackage[linguistics]{forest} |
| 150 |
\forestapplylibrarydefaults{linguistics, edges} |
| 151 |
%StopVisiblePreamble |
| 152 |
\begin{document} |
| 153 |
\begin{forest} |
| 154 |
[VP |
| 155 |
[DP] |
| 156 |
[V’ |
| 157 |
[V] |
| 158 |
[DP] |
| 159 |
] |
| 160 |
] |
| 161 |
\end{forest} |
| 162 |
\end{document} |
| 163 |
\end{externalDocument} |
| 164 |
\end{lstlisting} |
| 165 |
\end{minipage} |
| 166 |
\begin{minipage}{.39\linewidth} |
| 167 |
\begin{externalDocument}[ |
| 168 |
compiler=pdflatex,cleanup={log,aux},showFilename=false]{voss} |
| 169 |
\documentclass{standalone} |
| 170 |
%StartVisiblePreamble |
| 171 |
\usepackage{fontenc} |
| 172 |
\usepackage{libertinus} |
| 173 |
\usepackage[linguistics]{forest} |
| 174 |
\forestapplylibrarydefaults{linguistics, edges} |
| 175 |
%StopVisiblePreamble |
| 176 |
\begin{document} |
| 177 |
\begin{forest} |
| 178 |
[VP |
| 179 |
[DP] |
| 180 |
[V’ |
| 181 |
[V] |
| 182 |
[DP] |
| 183 |
] |
| 184 |
] |
| 185 |
\end{forest} |
| 186 |
\end{document} |
| 187 |
\end{externalDocument} |
| 188 |
\end{minipage} |
| 189 |
|
| 190 |
\subsection{Showing code and output of a Python example} |
| 191 |
The \ttIndex{png} image is created on the fly with the following arguments of \Lenv{externalDocument}: |
| 192 |
|
| 193 |
\begin{Verbatim} |
| 194 |
\begin{externalDocument}[ |
| 195 |
compiler=python3, |
| 196 |
code, |
| 197 |
ext=py, |
| 198 |
docType=py, |
| 199 |
usefancyvrb, |
| 200 |
grfOptions={width=\linewidth}]{python} |
| 201 |
... Python code ... |
| 202 |
\end{externalDocument} |
| 203 |
\end{Verbatim} |
| 204 |
|
| 205 |
The code which is declared as header and main can be marked by: |
| 206 |
|
| 207 |
\begin{Verbatim} |
| 208 |
\hv@extern@exampleType{py} |
| 209 |
{\NumChar StartVisibleMain} |
| 210 |
{\NumChar StopVisibleMain} |
| 211 |
{\NumChar StartVisiblePreamble} |
| 212 |
{\NumChar StopVisiblePreamble} |
| 213 |
\end{Verbatim} |
| 214 |
|
| 215 |
\Lcs{NumChar} is the default Python comment character \#\index{\#} and needs to be saved with a different |
| 216 |
catagory, which is done internally by the package. The complete definition of the code is: |
| 217 |
|
| 218 |
|
| 219 |
\begin{Verbatim} |
| 220 |
\begin{externalDocument}[ |
| 221 |
compiler=python3, |
| 222 |
code, |
| 223 |
ext=py, |
| 224 |
docType=py, |
| 225 |
usefancyvrb, |
| 226 |
grfOptions={width=\linewidth}]{python} |
| 227 |
import os |
| 228 |
#StartVisiblePreamble |
| 229 |
from PIL import Image |
| 230 |
import subprocess |
| 231 |
# drawing area (xa < xb and ya < yb) |
| 232 |
xa = -0.1716 |
| 233 |
xb = -0.1433 |
| 234 |
ya = 1.022 |
| 235 |
yb = 1.044 |
| 236 |
maxIt = 1024 # iterations |
| 237 |
imgx = 1000 # image size |
| 238 |
imgy = 750 |
| 239 |
image = Image.new("RGB", (imgx, imgy)) |
| 240 |
#StopVisiblePreamble |
| 241 |
|
| 242 |
#StartVisibleMain |
| 243 |
for y in range(imgy): |
| 244 |
cy = y * (yb - ya) / (imgy - 1) + ya |
| 245 |
for x in range(imgx): |
| 246 |
cx = x * (xb - xa) / (imgx - 1) + xa |
| 247 |
c = complex(cx, cy) |
| 248 |
z = 0 |
| 249 |
for i in range(maxIt): |
| 250 |
if abs(z) > 2.0: break |
| 251 |
z = z * z + c |
| 252 |
r = i % 4 * 6 |
| 253 |
g = i % 8 * 32 |
| 254 |
b = i % 16 * 16 |
| 255 |
image.putpixel((x, y), b * 65536 + g * 256 + r) |
| 256 |
#StopVisibleMain |
| 257 |
# now get the filename created by the latex document |
| 258 |
imageName = os.path.basename(os.path.splitext(__file__)[0])+".png" # get filename |
| 259 |
image.save(imageName, "PNG") |
| 260 |
\end{externalDocument} |
| 261 |
\end{Verbatim} |
| 262 |
|
| 263 |
And with using this code we get the image as png inserted. The given filename of the external |
| 264 |
document is |
| 265 |
internally extended by a consecutive number which isn't known to the \Index{Python} code. However, |
| 266 |
it is no problem in any programming language to get the name of a running file. The forlast |
| 267 |
line in the above code shows how it can be done with Python. |
| 268 |
|
| 269 |
|
| 270 |
\begin{externalDocument}[ |
| 271 |
compiler=python3, |
| 272 |
progpath=/usr/local/bin/, |
| 273 |
runs=1, |
| 274 |
code, |
| 275 |
ext=py, |
| 276 |
docType=py, |
| 277 |
usefancyvrb, |
| 278 |
grfOptions={width=\linewidth}]{python} |
| 279 |
import os |
| 280 |
#StartVisiblePreamble |
| 281 |
from PIL import Image |
| 282 |
import subprocess |
| 283 |
# drawing area (xa < xb and ya < yb) |
| 284 |
xa = -0.1716 |
| 285 |
xb = -0.1433 |
| 286 |
ya = 1.022 |
| 287 |
yb = 1.044 |
| 288 |
maxIt = 1024 # iterations |
| 289 |
imgx = 1000 # image size |
| 290 |
imgy = 750 |
| 291 |
image = Image.new("RGB", (imgx, imgy)) |
| 292 |
#StopVisiblePreamble |
| 293 |
|
| 294 |
#StartVisibleMain |
| 295 |
for y in range(imgy): |
| 296 |
cy = y * (yb - ya) / (imgy - 1) + ya |
| 297 |
for x in range(imgx): |
| 298 |
cx = x * (xb - xa) / (imgx - 1) + xa |
| 299 |
c = complex(cx, cy) |
| 300 |
z = 0 |
| 301 |
for i in range(maxIt): |
| 302 |
if abs(z) > 2.0: break |
| 303 |
z = z * z + c |
| 304 |
r = i % 4 * 6 |
| 305 |
g = i % 8 * 32 |
| 306 |
b = i % 16 * 16 |
| 307 |
image.putpixel((x, y), b * 65536 + g * 256 + r) |
| 308 |
#StopVisibleMain |
| 309 |
# now get the filename created by the latex document |
| 310 |
imageName = os.path.basename(os.path.splitext(__file__)[0]) # get filename |
| 311 |
image.save(imageName+".png", "PNG") |
| 312 |
\end{externalDocument} |
| 313 |
|
| 314 |
|
| 315 |
The external filename, extended by a consequtive number, kan be printed in the |
| 316 |
margin by setting the keyword \Lkeyword{showFilename}. In general it is printed |
| 317 |
in the outer margin or in twocolumn mode in the outer column. If the example is |
| 318 |
set in twocolumn mode but inside a starred floating environment over both |
| 319 |
column, then use the keyword \Lkeyword{outerFN}. Then \Lpack{hvextern} doesn't |
| 320 |
test for twocolumn mode. |
| 321 |
|
| 322 |
\enlargethispage{\normalbaselineskip} |
| 323 |
|
| 324 |
A vertical shift of the filename is possible by setting a length to the keyword \Lkeyword{shiftFN}, |
| 325 |
e.g. \texttt{shiftFN=5ex}. |
| 326 |
|
| 327 |
|
| 328 |
%\clearpage%%%%%%%%%%%% |
| 329 |
|
| 330 |
\begin{externalDocument}[grfOptions={width=0.95\linewidth}, |
| 331 |
compiler=xelatex,code,mpwidth=0.6\linewidth, |
| 332 |
crop,cleanup,usefancyvrb=false,ext=tex,showFilename=false]{voss} |
| 333 |
\documentclass{article} |
| 334 |
%StartVisiblePreamble |
| 335 |
\usepackage{tikz} |
| 336 |
\usepackage[hks,pantone,xcolor]{xespotcolor} |
| 337 |
%StopVisiblePreamble |
| 338 |
\pagestyle{empty} |
| 339 |
\begin{document} |
| 340 |
\SetPageColorSpace{HKS} |
| 341 |
\definecolor{HYellow}{spotcolor}{HKS05N,0.5} |
| 342 |
\definecolor{HRed}{spotcolor}{HKS14N,0.5} |
| 343 |
\definecolor{HBlue}{spotcolor}{HKS38N,0.5} |
| 344 |
\begin{tikzpicture}[scale=0.7,fill opacity=0.7] |
| 345 |
\fill[HYellow]( 90:1.2) circle (2); |
| 346 |
\fill[HRed] (210:1.2) circle (2); |
| 347 |
\fill[HBlue] (330:1.2) circle (2); |
| 348 |
\node at ( 90:2) {Typography}; |
| 349 |
\node at ( 210:2) {Design}; |
| 350 |
\node at ( 330:2) {Coding}; |
| 351 |
\node {\LaTeX}; |
| 352 |
\end{tikzpicture} |
| 353 |
\end{document} |
| 354 |
\end{externalDocument} |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
\section{Setting marker in the source} |
| 359 |
The marker for the code ranges which should be listed depend to the used programming language: |
| 360 |
|
| 361 |
\begin{verbatim} |
| 362 |
[...] |
| 363 |
%StartVisiblePreamble |
| 364 |
[... listed preamble code ] |
| 365 |
%StopVisiblePreamble |
| 366 |
[...] |
| 367 |
\begin{document} |
| 368 |
[...] |
| 369 |
\end{document} |
| 370 |
\end{verbatim} |
| 371 |
|
| 372 |
everything between \ttIndex{\%StartVisiblePreamble} and \ttIndex{\%StopVisiblePreamble} will be listed as |
| 373 |
preamble and in case of a \LaTeX\ source everything between |
| 374 |
\Lcs{begin\{document\}} and \Lcs{end\{document\}} as body. The marker must be defined with an own |
| 375 |
macro, e.g.: |
| 376 |
|
| 377 |
\begin{verbatim} |
| 378 |
\hv@extern@exampleType{py} |
| 379 |
{\NumChar StartVisibleMain} |
| 380 |
{\NumChar StopVisibleMain} |
| 381 |
{\NumChar StartVisiblePreamble} |
| 382 |
{\NumChar StopVisiblePreamble} |
| 383 |
\end{verbatim} |
| 384 |
|
| 385 |
\Lcs{NumChar} is the comment character \#, which needs a special handling. This version of \Lpack{hvextern} |
| 386 |
supports the following programming languages (option \Lkeyword{compiler}): |
| 387 |
\Lkeyval{mpost}, \Lkeyval{tex}, \Lkeyval{latex}, \Lkeyval{luatex}, |
| 388 |
\Lkeyval{python3}, \Lkeyval{perl}, \Lkeyval{lua}, \Lkeyval{xetex}, |
| 389 |
\Lkeyval{pdflatex}, \Lkeyval{lualatex}, \Lkeyval{xelatex}, and \Lkeyval{context}. The default |
| 390 |
is \Lkeyval{pdflatex}. The option \Lkeyword{docType} selects the config file, which must be one of |
| 391 |
\Lkeyval{context}, \Lkeyval{lua}, \Lkeyval{pl}, \Lkeyval{tex}, \Lkeyval{latex}, |
| 392 |
\Lkeyval{mp}, and \Lkeyval{py}. For Lua it is |
| 393 |
|
| 394 |
\begin{verbatim} |
| 395 |
\hv@extern@exampleType{lua} |
| 396 |
{--StartVisibleMain} |
| 397 |
{--StopVisibleMain} |
| 398 |
{--StartVisiblePreamble} |
| 399 |
{--StopVisiblePreamble} |
| 400 |
\end{verbatim} |
| 401 |
|
| 402 |
|
| 403 |
It defines the marker strings for the listed code sequences. |
| 404 |
In some cases you have to use multiple times the same value |
| 405 |
for different optional arguments, e.g. |
| 406 |
|
| 407 |
\begin{verbatim} |
| 408 |
ext=lua, compiler=lua, docType=lua, ... |
| 409 |
\end{verbatim} |
| 410 |
|
| 411 |
|
| 412 |
\section{Optional arguments} |
| 413 |
The default setting is always shown in brackets. |
| 414 |
\subsection{Programs and runs} |
| 415 |
|
| 416 |
The \Lkeyword{progpath} should only in some |
| 417 |
rare cases needed. In general all used compilers will be found by the system. A given \Lkeyword{progpath} |
| 418 |
must be end with a slash, e.g. \Lkeyval{./bin/} |
| 419 |
|
| 420 |
\begin{verbatim} |
| 421 |
\define@key{hv}{progpath}[]{\def\hv@extern@progpath{#1}} |
| 422 |
\define@key{hv}{compiler}[pdflatex]{\def\hv@extern@compiler{#1}} |
| 423 |
\define@key{hv}{runsequence}[]{\def\hv@extern@runsequence{#1}} |
| 424 |
\define@key{hv}{runs}[1]{\setcounter{hv@extern@runs}{#1}} |
| 425 |
\end{verbatim} |
| 426 |
|
| 427 |
For Windows the \Lkeyword{progpath} should always be written with slashes and not |
| 428 |
backslashes. e.g. |
| 429 |
|
| 430 |
\begin{verbatim} |
| 431 |
compiler=Rscript.exe, |
| 432 |
progpath=C:/Program Files/R/R-4.3.3/bin/x64/, |
| 433 |
\end{verbatim} |
| 434 |
|
| 435 |
For macOS it is something like this: |
| 436 |
|
| 437 |
\begin{externalDocument}[ |
| 438 |
compiler=Rscript, |
| 439 |
progpath=/opt/homebrew/bin/, |
| 440 |
grfOptions={width=0.5\linewidth}, |
| 441 |
code=true, |
| 442 |
usefancyvrb, |
| 443 |
ext=R, |
| 444 |
docType=R]{voss} |
| 445 |
#StartVisibleMain |
| 446 |
head(pressure) # Die ersten Werte der internen Datenliste |
| 447 |
pdf() # erzeugt die PDF "Rplots.pdf" |
| 448 |
plot(pressure) |
| 449 |
#StopVisibleMain |
| 450 |
\end{externalDocument} |
| 451 |
|
| 452 |
|
| 453 |
%\clearpage |
| 454 |
|
| 455 |
Instead of the optional arguments |
| 456 |
\Lkeyword{compiler}, \Lkeyword{biber}, and \Lkeyword{xindex} one can define an individual |
| 457 |
command sequence by using the optional argument |
| 458 |
\Lkeyword{runsequence}. It must be comma separated list: |
| 459 |
|
| 460 |
\begin{verbatim} |
| 461 |
runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex} |
| 462 |
\end{verbatim} |
| 463 |
|
| 464 |
\begin{externalDocument}[ |
| 465 |
grfOptions={width=0.30\linewidth}, |
| 466 |
pages={1,3,5}, |
| 467 |
pagesep=2pt, |
| 468 |
frame, |
| 469 |
runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, |
| 470 |
verbose, |
| 471 |
cleanup={log,aux,toc,bbl,blg}, |
| 472 |
code,docType=latex, |
| 473 |
lstOptions={columns=fixed}]{voss} |
| 474 |
\documentclass[paper=a5,parskip=half-,DIV=12,fontsize=12pt]{scrbook} |
| 475 |
%StartVisiblePreamble |
| 476 |
\usepackage[ngerman]{babel} |
| 477 |
\usepackage{libertinus,hvindex} |
| 478 |
\usepackage{makeidx}\makeindex |
| 479 |
\usepackage{biblatex}\addbibresource{biblatex-examples.bib} |
| 480 |
%StopVisiblePreamble |
| 481 |
\usepackage{blindtext} |
| 482 |
\begin{document} |
| 483 |
Sort with xindex \verb|-l DE --config AU| |
| 484 |
\blindtext |
| 485 |
\Index{Österreich} \Index{Öresund} |
| 486 |
\Index{Ostern} \Index{Ober} \Index{Oberin} |
| 487 |
\Index{Österreich} \Index{Öresund} |
| 488 |
\Index{Ödem} \Index{Oligarch} \Index{Oder} |
| 489 |
\Index{Goldmann} |
| 490 |
\printindex |
| 491 |
\nocite{*}\printbibliography |
| 492 |
\blindtext |
| 493 |
\blinddocument |
| 494 |
|
| 495 |
\end{document} |
| 496 |
\end{externalDocument} |
| 497 |
|
| 498 |
|
| 499 |
The following \Java-program creates the Mandelbrot set as png image. The valid setting for |
| 500 |
the environment \Lenv{externalDocument} is: |
| 501 |
|
| 502 |
\begin{verbatim} |
| 503 |
compiler=java,ext=java,docType=java, |
| 504 |
\end{verbatim} |
| 505 |
|
| 506 |
\begin{externalDocument}[ |
| 507 |
verbose, |
| 508 |
compiler=java,ext=java,code, |
| 509 |
docType=java,includegraphic, |
| 510 |
usefancyvrb,grfOptions={width=0.9\linewidth}]{java} |
| 511 |
import java.awt.Color; |
| 512 |
import java.awt.Graphics; |
| 513 |
import java.awt.image.BufferedImage; |
| 514 |
import java.awt.image.RenderedImage; |
| 515 |
import java.io.File; |
| 516 |
import javax.imageio.ImageIO; |
| 517 |
|
| 518 |
public class Main { |
| 519 |
|
| 520 |
//StartVisiblePreamble |
| 521 |
public static int iterZahl(final double cx, final double cy, int maxIt, |
| 522 |
final double radius) { |
| 523 |
// bestimmt Anzahl der Iterationen |
| 524 |
int zaehler = 0; |
| 525 |
double zx = 0.0, zy = 0.0, tmp; |
| 526 |
do { |
| 527 |
tmp = zx*zx - zy*zy + cx; |
| 528 |
zy = 2*zx*zy + cy; zx = tmp; |
| 529 |
zaehler++; |
| 530 |
} while (zx*zx + zy*zy <= radius && zaehler < maxIt); |
| 531 |
return zaehler; |
| 532 |
} |
| 533 |
//StopVisiblePreamble |
| 534 |
public static void main(String[] argv) throws Exception { |
| 535 |
String f_name = new File ((Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath()).getName(); |
| 536 |
String basename = f_name.replaceAll("\\.[^.]*$", ""); |
| 537 |
int imageBreite = 540, imageHoehe = 405; |
| 538 |
BufferedImage bufferedImage = new BufferedImage(imageBreite, imageHoehe, BufferedImage.TYPE_INT_RGB); |
| 539 |
Graphics g = bufferedImage.createGraphics(); |
| 540 |
//StartVisibleMain |
| 541 |
double xa = -2.5, xe = 0.7, ya = -1.2, ye = 1.2; // Ratio 20:15 |
| 542 |
double dx = (xe-xa)/(imageBreite-1), dy = (ye-ya)/(imageHoehe-1); |
| 543 |
double cx, cy; int R, G, B; |
| 544 |
double radius = 10.0; int maxIt = 1024; |
| 545 |
cx = xa; |
| 546 |
for (int sp = 0; sp < imageBreite; sp++) { |
| 547 |
cy = ye; // von oben nach unten |
| 548 |
for (int ze = 0; ze < imageHoehe; ze++) { |
| 549 |
int zIter = iterZahl(cx, cy, maxIt, radius); |
| 550 |
if (zIter == maxIt) { |
| 551 |
g.setColor(Color.WHITE); |
| 552 |
g.drawLine(sp, ze, sp, ze); |
| 553 |
} else { |
| 554 |
R = zIter % 4 * 6 ; G = zIter % 8 * 32; B = zIter % 16 * 16; |
| 555 |
g.setColor(new Color(R,G,B)); |
| 556 |
g.drawLine(sp, ze, sp, ze); |
| 557 |
} |
| 558 |
cy = cy - dy; |
| 559 |
} // for ze |
| 560 |
cx = cx + dx; |
| 561 |
} // for sp |
| 562 |
//StopVisibleMain |
| 563 |
g.dispose(); |
| 564 |
RenderedImage rendImage = bufferedImage; |
| 565 |
|
| 566 |
File file = new File(basename+".png"); |
| 567 |
ImageIO.write(rendImage, "png", file); |
| 568 |
} |
| 569 |
} |
| 570 |
\end{externalDocument} |
| 571 |
|
| 572 |
|
| 573 |
%$ |
| 574 |
|
| 575 |
|
| 576 |
\clearpage |
| 577 |
|
| 578 |
\subsection{Grafik options} |
| 579 |
\begin{verbatim} |
| 580 |
\define@key{hv}{grfOptions}[]{\def\hv@extern@grfOptions{#1}} |
| 581 |
\end{verbatim} |
| 582 |
|
| 583 |
The option is passed to \Lcs{includegraphics}, e.g. \verb|angle=90,width=\linewidth| for |
| 584 |
the follwing example. |
| 585 |
|
| 586 |
\begin{externalDocument}[grfOptions={angle=90,width=\linewidth}, |
| 587 |
compiler=xelatex,code,mpwidth=0.6\linewidth, |
| 588 |
crop,cleanup]{voss} |
| 589 |
\documentclass{article} |
| 590 |
%StartVisiblePreamble |
| 591 |
\usepackage{tikz} |
| 592 |
\usepackage[hks,pantone,xcolor]{xespotcolor} |
| 593 |
%StopVisiblePreamble |
| 594 |
\pagestyle{empty} |
| 595 |
\begin{document} |
| 596 |
\SetPageColorSpace{HKS} |
| 597 |
\definecolor{HYellow}{spotcolor}{HKS05N,0.5} |
| 598 |
\definecolor{HRed}{spotcolor}{HKS14N,0.5} |
| 599 |
\definecolor{HBlue}{spotcolor}{HKS38N,0.5} |
| 600 |
\begin{tikzpicture}[scale=0.7,fill opacity=0.7] |
| 601 |
\fill[HYellow] ( 90:1.2) circle (2); |
| 602 |
\fill[HRed] (210:1.2) circle (2); |
| 603 |
\fill[HBlue] (330:1.2) circle (2); |
| 604 |
\node at ( 90:2) {Typography}; |
| 605 |
\node at ( 210:2) {Design}; |
| 606 |
\node at ( 330:2) {Coding}; |
| 607 |
\node {\LaTeX}; |
| 608 |
\end{tikzpicture} |
| 609 |
\end{document} |
| 610 |
\end{externalDocument} |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
%\newpage%%%%%%%%%%% |
| 615 |
|
| 616 |
|
| 617 |
\subsection{Listings options} |
| 618 |
|
| 619 |
\begin{verbatim} |
| 620 |
\define@key{hv}{lstOptions}[]{\def\hv@extern@lstOptions{#1}} |
| 621 |
\end{verbatim} |
| 622 |
|
| 623 |
The option is passed either to \Lcs{lstinputlisting}, or, if \Lkeyword{usefancyvrb} is active, |
| 624 |
to \Lcs{VerbatimInput}. The following example uses |
| 625 |
|
| 626 |
\begin{verbatim} |
| 627 |
lstOptions={basicstyle=\sffamily\itshape\scriptsize}, |
| 628 |
\end{verbatim} |
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
\begin{externalDocument}[ |
| 633 |
grfOptions={width=\linewidth}, |
| 634 |
lstOptions={basicstyle=\sffamily\itshape\scriptsize}, |
| 635 |
compiler=lualatex, |
| 636 |
code, |
| 637 |
mpwidth=0.6\linewidth, |
| 638 |
crop, |
| 639 |
cleanup, |
| 640 |
docType=latex]{voss} |
| 641 |
\RequirePackage{pdfmanagement-testphase} |
| 642 |
\DeclareDocumentMetadata{} |
| 643 |
\documentclass{article} |
| 644 |
%StartVisiblePreamble |
| 645 |
\usepackage{pst-calendar} |
| 646 |
%StopVisiblePreamble |
| 647 |
\pagestyle{empty} |
| 648 |
\begin{document} |
| 649 |
\psscalebox{0.3}{% |
| 650 |
\psCalDodecaeder[Year=2022,style=april]% |
| 651 |
} |
| 652 |
\end{document} |
| 653 |
\end{externalDocument} |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
\subsection{Background color} |
| 658 |
|
| 659 |
There are different colors for the preamble and body listing: the backgrund and frame color. |
| 660 |
\begin{verbatim} |
| 661 |
\define@key{hv}{BGpreamble}[black12]{\def\hv@extern@BGpreamble{#1}} |
| 662 |
\define@key{hv}{BGbody}[black8]{\def\hv@extern@BGbody{#1}} |
| 663 |
\define@key{hv}{BOpreamble}[black12]{\def\hv@extern@BOpreamble{#1}} |
| 664 |
\define@key{hv}{BObody}[black8]{\def\hv@extern@BObody{#1}} |
| 665 |
\end{verbatim} |
| 666 |
|
| 667 |
The options are passed to \Lpack{tcolorbox} and preset to \Lcolor{black"!12} and \Lcolor{black"!8}. |
| 668 |
The color of the frame is set to the same values, hence not seen. The following example uses |
| 669 |
|
| 670 |
\begin{verbatim} |
| 671 |
BGpreamble=red!10, BOpreamble=red, |
| 672 |
BGbody=blue!8, BObody=blue, |
| 673 |
\end{verbatim} |
| 674 |
|
| 675 |
%\clearpage |
| 676 |
|
| 677 |
\begin{externalDocument}[ |
| 678 |
grfOptions={width=\linewidth}, |
| 679 |
lstOptions={fontsize=\small,fontfamily=tt}, |
| 680 |
compiler=lualatex, |
| 681 |
BGpreamble=red!10, BOpreamble=red, |
| 682 |
BGbody=blue!8, BObody=blue, |
| 683 |
code, |
| 684 |
mpwidth=0.6\linewidth, |
| 685 |
crop, |
| 686 |
cleanup, |
| 687 |
usefancyvrb, |
| 688 |
docType=latex]{voss} |
| 689 |
\RequirePackage{pdfmanagement-testphase} |
| 690 |
\DeclareDocumentMetadata{} |
| 691 |
\documentclass{article} |
| 692 |
%StartVisiblePreamble |
| 693 |
\usepackage{pst-calendar} |
| 694 |
%StopVisiblePreamble |
| 695 |
\pagestyle{empty} |
| 696 |
\begin{document} |
| 697 |
\psscalebox{0.3}{% |
| 698 |
\psCalDodecaeder[Year=2022,style=may]% |
| 699 |
} |
| 700 |
\end{document} |
| 701 |
\end{externalDocument} |
| 702 |
|
| 703 |
\subsection{Type of the source code} |
| 704 |
|
| 705 |
The current version of \Lpack{hvextern} supports code written as |
| 706 |
\MP, \plainTeX, \LaTeX, \ConTeXt, and Python. Every type has its own keywords for the |
| 707 |
linerange which should be printed for the preamble and |
| 708 |
the body. For example the \texttt{latex} config is: |
| 709 |
|
| 710 |
\begin{verbatim} |
| 711 |
\hv@extern@exampleType{latex}% for _all_LaTeX engines |
| 712 |
{\string\begin\string{document\string}}% |
| 713 |
{\string\end\string{document\string}}% |
| 714 |
{\perCent StartVisiblePreamble}% |
| 715 |
{\perCent StopVisiblePreamble}% |
| 716 |
|
| 717 |
% only for the sequence latex->dvips->ps2pdf |
| 718 |
\def\hv@extern@runLATEX#1#2#3#4{% path compiler file extension |
| 719 |
\ifhv@extern@verbose \typeout{>>>> running #1#2 #3#4}\fi |
| 720 |
\ShellEscape{#1#2\space #3#4}% |
| 721 |
\ifhv@extern@verbose \typeout{>>>> running #1dvips #3}\fi |
| 722 |
\ShellEscape{#1dvips\space #3.dvi}% |
| 723 |
\ifhv@extern@verbose \typeout{>>>> running ps2pdf #3.ps}\fi |
| 724 |
\ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}% |
| 725 |
} |
| 726 |
\end{verbatim} |
| 727 |
|
| 728 |
If a source needs more than running the defined compiler, it must be defined by a macro |
| 729 |
\begin{verbatim} |
| 730 |
\def\hv@extern@run<NAME>#1#2#3#4{% path compiler file extension |
| 731 |
...} |
| 732 |
\end{verbatim} |
| 733 |
|
| 734 |
The type of the source code can be different to the compiler, e.g. source \Lkeyval{latex}, |
| 735 |
but compiler \Lkeyval{lualatex}. |
| 736 |
|
| 737 |
\subsection{Output more than one page} |
| 738 |
The pages which should be printed can be defined by |
| 739 |
|
| 740 |
|
| 741 |
\begin{verbatim} |
| 742 |
\define@key{hv}{pages}[1]{\def\hv@extern@pages{#1}} |
| 743 |
\define@key{hv}{pagesep}[1em]{\hv@extern@pagesep=#1} |
| 744 |
\define@boolkey{hv}[hv@extern@]{frame}[true]{} |
| 745 |
\end{verbatim} |
| 746 |
|
| 747 |
With \Lkeyword{frame} the pages can be framed (internally by \Lcs{fbox}). |
| 748 |
It is leaved to the user to choose the correct image width for the pages. |
| 749 |
The separation between the pages is defined by the length \Lkeyword{pagesep}. |
| 750 |
The following example uses: |
| 751 |
|
| 752 |
\begin{verbatim} |
| 753 |
pages={1,2,3}, |
| 754 |
pagesep=2pt, |
| 755 |
grfOptions={width=0.3\linewidth}, |
| 756 |
compiler=lualatex, runs=2, % for the TOC |
| 757 |
frame, |
| 758 |
\end{verbatim} |
| 759 |
|
| 760 |
\begin{externalDocument}[ |
| 761 |
pages={1,2,3}, |
| 762 |
pagesep=2pt, |
| 763 |
shiftFN=5ex, |
| 764 |
grfOptions={width=0.3\linewidth}, |
| 765 |
% lstOptions={fontsize=\small,fontfamily=tt}, |
| 766 |
compiler=lualatex, runs=2, |
| 767 |
BGpreamble=red!10, BOpreamble=red, |
| 768 |
BGbody=blue!8, BObody=blue, |
| 769 |
code, |
| 770 |
% mpwidth=0.6\linewidth, |
| 771 |
% crop, |
| 772 |
cleanup, |
| 773 |
frame, |
| 774 |
% usefancyvrb, |
| 775 |
% float, |
| 776 |
% caption={An example for Coxeter images}, |
| 777 |
% label=img:cox, |
| 778 |
docType=latex]{voss} |
| 779 |
\documentclass{article} |
| 780 |
%StartVisiblePreamble |
| 781 |
\usepackage[american]{babel} |
| 782 |
\usepackage{libertinus} |
| 783 |
\usepackage{blindtext} |
| 784 |
%StopVisiblePreamble |
| 785 |
\pagestyle{empty} |
| 786 |
\begin{document} |
| 787 |
\title{A multipage example} |
| 788 |
\author{Erasmus von Rotterdam} |
| 789 |
\maketitle |
| 790 |
\tableofcontents |
| 791 |
\blinddocument |
| 792 |
\end{document} |
| 793 |
\end{externalDocument} |
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
\subsection{Output as floating object with caption and label} |
| 799 |
|
| 800 |
By default the images are not inserted as a float. This can be changed by |
| 801 |
the keyword \Lkeyword{float}, a caption and a label are optional. The float type is always |
| 802 |
\Lenv{figure}. |
| 803 |
|
| 804 |
\begin{verbatim} |
| 805 |
\define@boolkey{hv}[hv@extern@]{float}[true]{} |
| 806 |
\define@key{hv}{floatsetting}[]{\def\hv@extern@floatsetting{#1}} |
| 807 |
\define@key{hv}{caption}[]{\def\hv@extern@caption{#1}} |
| 808 |
\define@key{hv}{label}[]{\def\hv@extern@label{#1}} |
| 809 |
\end{verbatim} |
| 810 |
|
| 811 |
The image Figure~\ref{img:cox} shows an example for a floating object, which uses the floatsetting \verb|!htb|, |
| 812 |
which is the default. Using a caption and a label are optional. |
| 813 |
|
| 814 |
\begin{externalDocument}[ |
| 815 |
grfOptions={width=\linewidth}, |
| 816 |
lstOptions={fontsize=\small,fontfamily=tt}, |
| 817 |
% lstOptions={basicstyle=\small\ttfamily}, |
| 818 |
compiler=lualatex, |
| 819 |
BGpreamble=red!10, BOpreamble=red, |
| 820 |
BGbody=blue!8, BObody=blue, |
| 821 |
code, |
| 822 |
% mpwidth=0.6\linewidth, |
| 823 |
crop, |
| 824 |
cleanup, |
| 825 |
usefancyvrb, |
| 826 |
float, |
| 827 |
floatsetting=!ht, |
| 828 |
caption={An example for Coxeter images}, |
| 829 |
label=img:cox, |
| 830 |
docType=latex]{voss} |
| 831 |
\RequirePackage{pdfmanagement-testphase} |
| 832 |
\DeclareDocumentMetadata{} |
| 833 |
\documentclass{article} |
| 834 |
%StartVisiblePreamble |
| 835 |
\usepackage{pst-coxeterp} |
| 836 |
%StopVisiblePreamble |
| 837 |
\pagestyle{empty} |
| 838 |
\begin{document} |
| 839 |
\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=2]\end{pspicture} |
| 840 |
\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=3]\end{pspicture} |
| 841 |
\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=5]\end{pspicture} |
| 842 |
\begin{pspicture}(-1,-1)(1,1)\Simplex[dimension=7]\end{pspicture} |
| 843 |
\end{document} |
| 844 |
\end{externalDocument} |
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
%\clearpage%%%%%%%%%%%%%%%%% |
| 849 |
|
| 850 |
|
| 851 |
\subsection{Cropping the PDF} |
| 852 |
Instead of using the \Index{documentclass} \Lclass{standalone}, which already crops the created PDF, |
| 853 |
one can use the optional argument \Lkeyword{crop}. |
| 854 |
|
| 855 |
\begin{verbatim} |
| 856 |
\define@boolkey{hv}[hv@extern@]{crop}[true]{} |
| 857 |
\define@key{hv}{cropmargin}[2]{\def\hv@extern@cropmargin{#1 }}% length in pt |
| 858 |
\end{verbatim} |
| 859 |
|
| 860 |
|
| 861 |
It is also possible to crop a document with more than one page. In this case the |
| 862 |
beginning and end of the pages should be on the same height. Otherwise the pages |
| 863 |
will have different heights after \Index{cropping} (see next image). |
| 864 |
The follwoing example was created with |
| 865 |
|
| 866 |
\begin{verbatim} |
| 867 |
pages={1,2,3}, |
| 868 |
pagesep=2pt, |
| 869 |
grfOptions={width=0.3\linewidth}, |
| 870 |
compiler=lualatex, runs=2, % for the TOC |
| 871 |
frame, |
| 872 |
crop, cropmargin=5,% 5pt margin |
| 873 |
\end{verbatim} |
| 874 |
|
| 875 |
\begin{externalDocument}[ |
| 876 |
pages={1,2,3}, |
| 877 |
pagesep=2pt, |
| 878 |
grfOptions={width=0.3\linewidth}, |
| 879 |
% lstOptions={fontsize=\small,fontfamily=tt}, |
| 880 |
compiler=lualatex, runs=2, |
| 881 |
BGpreamble=red!10, BOpreamble=red, |
| 882 |
BGbody=blue!8, BObody=blue, |
| 883 |
code, |
| 884 |
% mpwidth=0.6\linewidth, |
| 885 |
crop, cropmargin=5, |
| 886 |
cleanup, |
| 887 |
frame, |
| 888 |
% usefancyvrb, |
| 889 |
% float, |
| 890 |
% caption={An example for Coxeter images}, |
| 891 |
% label=img:cox, |
| 892 |
docType=latex]{voss} |
| 893 |
\documentclass{article} |
| 894 |
%StartVisiblePreamble |
| 895 |
\usepackage[american]{babel} |
| 896 |
\usepackage{libertinus} |
| 897 |
\usepackage{blindtext} |
| 898 |
\pagestyle{headings} |
| 899 |
%StopVisiblePreamble |
| 900 |
\begin{document} |
| 901 |
\title{A multipage example} |
| 902 |
\author{Erasmus von Rotterdam} |
| 903 |
\maketitle |
| 904 |
\tableofcontents |
| 905 |
\Blinddocument |
| 906 |
\end{document} |
| 907 |
\end{externalDocument} |
| 908 |
|
| 909 |
|
| 910 |
\subsection{Code and output side by side} |
| 911 |
By default the code and the output is on top of each other. With setting the |
| 912 |
width of a minipage with \Lkeyword{mpwidth} greater than 0\,pt the output will be side by side. |
| 913 |
|
| 914 |
\begin{verbatim} |
| 915 |
\define@key{hv}{mpwidth}[0pt]{\setlength\hv@extern@mpwidth{#1}} |
| 916 |
\define@key{hv}{mpvalign}[0pt]{\def\hv@extern@mpvalign{#1}} |
| 917 |
\end{verbatim} |
| 918 |
|
| 919 |
\Lkeyword{mpwidth} is the width of the code. The rest of the line, minus 1em for the space between |
| 920 |
the minipages, will be the possible |
| 921 |
width for the output and will be calculated automatically. The two \Index{minipages} are |
| 922 |
aligned by defaults to its top. This can be changed by setting \Lkeyword{mpvalign} to \Lkeyval{c} |
| 923 |
or \Lkeyval{b}. |
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
\subsection{Horizontal alignment of the output} |
| 928 |
|
| 929 |
%\begin{verbatim} |
| 930 |
%\define@key{hv}{align}[\centering]{\def\hv@extern@align{#1}} |
| 931 |
%\end{verbatim} |
| 932 |
|
| 933 |
%\textbf{the default} |
| 934 |
% |
| 935 |
\begin{verbatim} |
| 936 |
align=\centering, % default |
| 937 |
\end{verbatim} |
| 938 |
% |
| 939 |
\begin{externalDocument}[ |
| 940 |
compiler=lualatex, runs=2, |
| 941 |
BGpreamble=red!10, BOpreamble=red, |
| 942 |
BGbody=blue!8, BObody=blue, |
| 943 |
code, |
| 944 |
showFilename=false, |
| 945 |
crop, |
| 946 |
cleanup, |
| 947 |
aboveskip=0pt,belowskip=0pt, |
| 948 |
docType=latex]{voss} |
| 949 |
\documentclass{article} |
| 950 |
\pagestyle{empty} |
| 951 |
\begin{document} |
| 952 |
\rule{0.5\linewidth}{5mm} |
| 953 |
\end{document} |
| 954 |
\end{externalDocument} |
| 955 |
|
| 956 |
%\textbf{Left aligned} |
| 957 |
|
| 958 |
\begin{verbatim} |
| 959 |
align=\raggedright, |
| 960 |
\end{verbatim} |
| 961 |
|
| 962 |
\begin{externalDocument}[ |
| 963 |
align=\raggedright, |
| 964 |
compiler=lualatex, runs=2, |
| 965 |
BGpreamble=red!10, BOpreamble=red, |
| 966 |
BGbody=blue!8, BObody=blue, |
| 967 |
showFilename=false, |
| 968 |
code, |
| 969 |
crop, |
| 970 |
cleanup, |
| 971 |
aboveskip=0pt,belowskip=0pt, |
| 972 |
docType=latex]{voss} |
| 973 |
\documentclass{article} |
| 974 |
\pagestyle{empty} |
| 975 |
\begin{document} |
| 976 |
\rule{0.5\linewidth}{5mm} |
| 977 |
\end{document} |
| 978 |
\end{externalDocument} |
| 979 |
|
| 980 |
%\textbf{Right aligned} |
| 981 |
|
| 982 |
\begin{verbatim} |
| 983 |
align=\raggedleft, |
| 984 |
\end{verbatim} |
| 985 |
|
| 986 |
|
| 987 |
\begin{externalDocument}[ |
| 988 |
align=\raggedleft, |
| 989 |
compiler=lualatex, runs=2, |
| 990 |
BGpreamble=red!10, BOpreamble=red, |
| 991 |
BGbody=blue!8, BObody=blue, |
| 992 |
code, |
| 993 |
showFilename=false, |
| 994 |
crop, |
| 995 |
cleanup, |
| 996 |
aboveskip=0pt,belowskip=0pt, |
| 997 |
docType=latex]{voss} |
| 998 |
\documentclass{article} |
| 999 |
\pagestyle{empty} |
| 1000 |
\begin{document} |
| 1001 |
\rule{0.5\linewidth}{5mm} |
| 1002 |
\end{document} |
| 1003 |
\end{externalDocument} |
| 1004 |
|
| 1005 |
|
| 1006 |
%Now the same for side by side output. |
| 1007 |
|
| 1008 |
%\textbf{the default -- side by side} |
| 1009 |
\begin{verbatim} |
| 1010 |
align=\centering, mpwidth=0.5\linewidth, % default for side by side |
| 1011 |
\end{verbatim} |
| 1012 |
|
| 1013 |
\begin{externalDocument}[ |
| 1014 |
compiler=lualatex, runs=2, |
| 1015 |
BGpreamble=red!10, BOpreamble=red, |
| 1016 |
BGbody=blue!8, BObody=blue, |
| 1017 |
code, |
| 1018 |
crop, |
| 1019 |
showFilename=false, |
| 1020 |
cleanup, |
| 1021 |
mpwidth=0.5\linewidth, |
| 1022 |
aboveskip=0pt,belowskip=0pt, |
| 1023 |
docType=latex]{voss} |
| 1024 |
\documentclass{article} |
| 1025 |
\pagestyle{empty} |
| 1026 |
\begin{document} |
| 1027 |
\rule{0.25\linewidth}{5mm} |
| 1028 |
\end{document} |
| 1029 |
\end{externalDocument} |
| 1030 |
|
| 1031 |
%\textbf{Left aligned -- side by side} |
| 1032 |
|
| 1033 |
\begin{verbatim} |
| 1034 |
align=\raggedright, mpwidth=0.5\linewidth, |
| 1035 |
\end{verbatim} |
| 1036 |
|
| 1037 |
\begin{externalDocument}[ |
| 1038 |
align=\raggedright, |
| 1039 |
compiler=lualatex, runs=2, |
| 1040 |
BGpreamble=red!10, BOpreamble=red, |
| 1041 |
BGbody=blue!8, BObody=blue, |
| 1042 |
code, |
| 1043 |
showFilename=false, |
| 1044 |
crop, |
| 1045 |
cleanup, |
| 1046 |
mpwidth=0.5\linewidth, |
| 1047 |
aboveskip=0pt,belowskip=0pt, |
| 1048 |
docType=latex]{voss} |
| 1049 |
\documentclass{article} |
| 1050 |
\pagestyle{empty} |
| 1051 |
\begin{document} |
| 1052 |
\rule{0.25\linewidth}{5mm} |
| 1053 |
\end{document} |
| 1054 |
\end{externalDocument} |
| 1055 |
|
| 1056 |
%\textbf{Right aligned -- side by side} |
| 1057 |
|
| 1058 |
\begin{verbatim} |
| 1059 |
align=\raggedleft, mpwidth=0.5\linewidth, |
| 1060 |
\end{verbatim} |
| 1061 |
|
| 1062 |
|
| 1063 |
\begin{externalDocument}[ |
| 1064 |
align=\raggedleft, |
| 1065 |
compiler=lualatex, runs=2, |
| 1066 |
BGpreamble=red!10, BOpreamble=red, |
| 1067 |
BGbody=blue!8, BObody=blue, |
| 1068 |
code, |
| 1069 |
showFilename=false, |
| 1070 |
crop, |
| 1071 |
cleanup, |
| 1072 |
mpwidth=0.5\linewidth, |
| 1073 |
aboveskip=0pt,belowskip=0pt, |
| 1074 |
docType=latex]{voss} |
| 1075 |
\documentclass{article} |
| 1076 |
\pagestyle{empty} |
| 1077 |
\begin{document} |
| 1078 |
\rule{0.25\linewidth}{5mm} |
| 1079 |
\end{document} |
| 1080 |
\end{externalDocument} |
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
\subsection{Inline images} |
| 1086 |
By default code and image are own paragraphs. With the optional argument \Lkeyword{inline} the created |
| 1087 |
image can be part of the \Index{current line}. This may make sense, if you need characters which are |
| 1088 |
not part of your current font. |
| 1089 |
|
| 1090 |
\begin{verbatim} |
| 1091 |
\define@boolkey{hv}[hv@extern@]{inline}[true]{% |
| 1092 |
\hv@extern@codefalse |
| 1093 |
\hv@extern@showFilenamefalse} |
| 1094 |
\end{verbatim} |
| 1095 |
|
| 1096 |
With the setting \LKeyset{inline=true} the optional keyword \Lkeyword{code} and \Lkeyword{showFilename} |
| 1097 |
is automatically set to false. The |
| 1098 |
next Chinese characters \label{inline-exa} |
| 1099 |
\begin{externalDocument}[ |
| 1100 |
compiler=xelatex, inline, runs=2, grfOptions={height=8pt}, |
| 1101 |
crop, cropmargin=0, vshift=-1pt,usefancyvrb, |
| 1102 |
cleanup, docType=latex]{voss}% |
| 1103 |
\documentclass{ctexart} |
| 1104 |
\pagestyle{empty} |
| 1105 |
\begin{document} |
| 1106 |
美好的一天 |
| 1107 |
\end{document} |
| 1108 |
\end{externalDocument} |
| 1109 |
are inserted as \Index{inline image} without showing the code. The complete code looks like: |
| 1110 |
|
| 1111 |
|
| 1112 |
\let\myFont\CodeTwo |
| 1113 |
|
| 1114 |
\begin{Verbatim}[fontfamily=myFont] |
| 1115 |
With \Lkeyset{inline} the optional argument \Lkeyword{code} is |
| 1116 |
automatically set to false. The next Chinese characters |
| 1117 |
\begin{externalDocument}[vshift=-1pt, |
| 1118 |
compiler=xelatex, inline, runs=2, grfOptions={height=8pt}, |
| 1119 |
crop, cropmargin=0, cleanup, docType=latex]{voss} |
| 1120 |
\documentclass{ctexart} |
| 1121 |
\pagestyle{empty} |
| 1122 |
\begin{document} |
| 1123 |
美好的一天 |
| 1124 |
\end{document} |
| 1125 |
\end{externalDocument} |
| 1126 |
are inserted as inline image without showing the code. The complete |
| 1127 |
code looks like: |
| 1128 |
\end{Verbatim} |
| 1129 |
|
| 1130 |
With the keyword \Lkeyword{vshift} the inserted image can be moed in vertically direction. |
| 1131 |
|
| 1132 |
\subsection{Input text instead of an image} |
| 1133 |
By default the created pdf which can be, of course, only text, will be inserted by \Lcs{includegraphics}. |
| 1134 |
If you have only text as output and don't want to create a pdf you can insert this kind of |
| 1135 |
output as verbatim text by setting \Lkeyset{includegraphic=false}. |
| 1136 |
|
| 1137 |
\begin{verbatim} |
| 1138 |
\define@boolkey{hv}[hv@extern@]{includegraphic}[true]{} |
| 1139 |
\end{verbatim} |
| 1140 |
|
| 1141 |
|
| 1142 |
The textfile must have the same main filename with the extension |
| 1143 |
\Lext{txt}. As already mentioned, in every programming language you can get the current |
| 1144 |
used filename from within the code itself. The following \Perl example which calculates the |
| 1145 |
\Index{Kaprekar} constants uses |
| 1146 |
|
| 1147 |
\begin{verbatim} |
| 1148 |
my $filename = $0; # the current filename |
| 1149 |
$filename =~ s/\.pl//; # without extension .pl |
| 1150 |
$filename = "${filename}.txt"; # for the output |
| 1151 |
\end{verbatim} |
| 1152 |
|
| 1153 |
Only for some completeness: a Kaprekar constant is a number $A$ with $\max(A)-\min(A)=A$. |
| 1154 |
$\max$ and $\min$ are the |
| 1155 |
sorted digits of the number $A$: $495=954-459$. |
| 1156 |
|
| 1157 |
|
| 1158 |
\begin{externalDocument}[ |
| 1159 |
compiler=perl, docType=pl, ext=pl, includegraphic=false, |
| 1160 |
code, mpwidth=0.6\linewidth]{voss} |
| 1161 |
#!/usr/bin/perl |
| 1162 |
# |
| 1163 |
# Herbert Voss 2005-05-31 |
| 1164 |
# |
| 1165 |
#StartVisiblePreamble |
| 1166 |
my $zahl = 1; |
| 1167 |
my $anfang = 1; |
| 1168 |
my $ende = 9; |
| 1169 |
#StopVisiblePreamble |
| 1170 |
my $filename = $0; # the current filename |
| 1171 |
$filename =~ s/\.pl//; # without extension .pl |
| 1172 |
$filename = "${filename}.txt"; # for the output |
| 1173 |
my $found = 0; |
| 1174 |
open(my $fh, '>', $filename); |
| 1175 |
|
| 1176 |
#StartVisibleMain |
| 1177 |
print $fh "Finding Kaprekarconstants ...\n"; |
| 1178 |
while ($zahl < 8) { |
| 1179 |
print $fh "${zahl}-stellig: "; |
| 1180 |
foreach ($anfang...$ende) { # for every row $_ |
| 1181 |
@Zeichen = split(//,$_); |
| 1182 |
$Min = join("",sort(@Zeichen)); |
| 1183 |
$Max = reverse($Min); |
| 1184 |
$Dif=$Max-$Min; |
| 1185 |
if($_ eq $Dif) { |
| 1186 |
$found = 1; |
| 1187 |
print $fh $_,", "; |
| 1188 |
} |
| 1189 |
} |
| 1190 |
if (!$found) { print $fh "---\n"; } |
| 1191 |
else { print $fh "\n"; } |
| 1192 |
$found = false; |
| 1193 |
$zahl = $zahl+1; |
| 1194 |
$anfang = $anfang*10; |
| 1195 |
$ende = $ende*10; |
| 1196 |
} |
| 1197 |
#StopVisibleMain |
| 1198 |
close $fh; |
| 1199 |
\end{externalDocument} |
| 1200 |
|
| 1201 |
|
| 1202 |
%$ |
| 1203 |
Another example with running \Lua to calculate and print the \Index{Pascal's triangle}. The internal filename |
| 1204 |
is available with |
| 1205 |
|
| 1206 |
\begin{verbatim} |
| 1207 |
local filename = arg[0] |
| 1208 |
local shortFN = str:match("(.+)%..+") -- delete extension |
| 1209 |
outFile = io.open(shortFN..".txt","w+") -- open external file |
| 1210 |
\end{verbatim} |
| 1211 |
|
| 1212 |
|
| 1213 |
\begin{externalDocument}[ |
| 1214 |
compiler=lua, docType=lua, ext=lua, includegraphic=false, |
| 1215 |
code, usefancyvrb=false,textOptions={basicstyle=\ttfamily\footnotesize}, |
| 1216 |
shiftFN=6ex]{voss} |
| 1217 |
#!/usr/bin/env lua |
| 1218 |
local filename = arg[0] |
| 1219 |
local shortFN = filename:match("(.+)%..+") |
| 1220 |
outFile = io.open(shortFN..".txt","w+") |
| 1221 |
|
| 1222 |
--StartVisiblePreamble |
| 1223 |
function nextrow(t) |
| 1224 |
local ret = {} |
| 1225 |
t[0], t[#t+1] = 0, 0 |
| 1226 |
for i = 1, #t do ret[i] = t[i-1] + t[i] end |
| 1227 |
return ret |
| 1228 |
end |
| 1229 |
|
| 1230 |
function triangle(n) |
| 1231 |
t = {1} |
| 1232 |
for i = 1, n do |
| 1233 |
m = (n - i) |
| 1234 |
for j = 1,m do outFile:write(" ") end |
| 1235 |
for k = 1,i do outFile:write(string.format("%8s",t[k])) end |
| 1236 |
outFile:write("\n") |
| 1237 |
t = nextrow(t) |
| 1238 |
end |
| 1239 |
end |
| 1240 |
--StopVisiblePreamble |
| 1241 |
|
| 1242 |
--StartVisibleMain |
| 1243 |
triangle(10) |
| 1244 |
--StopVisibleMain |
| 1245 |
outFile:close() |
| 1246 |
\end{externalDocument} |
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
\subsection{Running additional external programs} |
| 1254 |
|
| 1255 |
For a \LaTeX\ additional programs for \Index{bibliography}, \Index{index}, a.s.o. maybe needed. |
| 1256 |
|
| 1257 |
\begin{verbatim} |
| 1258 |
\define@boolkey{hv}[hv@extern@]{biber}[true]{} |
| 1259 |
\define@boolkey{hv}[hv@extern@]{xindex}[true]{} |
| 1260 |
\define@key{hv}{xindexOptions}[]{\def\hv@extern@xindexOptions{#1}} |
| 1261 |
\define@key{hv}{runsequence}[]{\def\hv@extern@runsequence{#1}} |
| 1262 |
\end{verbatim} |
| 1263 |
|
| 1264 |
The \Lkeyword{biber} run needs no additional options, but for \Lkeyword{xindex} it maybe useful. |
| 1265 |
The following examples uses |
| 1266 |
|
| 1267 |
\begin{verbatim} |
| 1268 |
\begin{externalDocument}[ |
| 1269 |
compiler=lualatex, runs=2, pages=2,crop, |
| 1270 |
xindex, xindexOptions={-l DE --config AU}, |
| 1271 |
mpwidth=0.6\linewidth, usefancyvrb=false, |
| 1272 |
docType=latex, |
| 1273 |
... |
| 1274 |
]{voss} |
| 1275 |
\end{verbatim} |
| 1276 |
|
| 1277 |
%\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase,FakeStretch=0.9] |
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
\begin{externalDocument}[ |
| 1282 |
grfOptions={scale=0.75}, |
| 1283 |
compiler=lualatex, runs=2, |
| 1284 |
BGpreamble=red!10, BOpreamble=red, |
| 1285 |
BGbody=blue!8, BObody=blue, |
| 1286 |
code, |
| 1287 |
pages=2, |
| 1288 |
crop, |
| 1289 |
cleanup, |
| 1290 |
xindex, |
| 1291 |
xindexOptions={-l DE --config AU}, |
| 1292 |
mpwidth=0.6\linewidth, |
| 1293 |
usefancyvrb=false, |
| 1294 |
docType=latex]{voss} |
| 1295 |
\documentclass[paper=a6,DIV=18,parskip=half-]{scrartcl} |
| 1296 |
\pagestyle{empty} |
| 1297 |
\usepackage{libertinus} |
| 1298 |
\usepackage{juliamono} |
| 1299 |
\usepackage[ngerman]{babel} |
| 1300 |
\usepackage{multicol} |
| 1301 |
\makeatletter |
| 1302 |
\def\theindex{% only for demonstration |
| 1303 |
\newpage |
| 1304 |
\section*{\indexname} |
| 1305 |
\begin{multicols}{2} |
| 1306 |
\parskip\z@ \@plus .3\p@\relax \parindent\z@ |
| 1307 |
\let\item\@idxitem} |
| 1308 |
\def\endtheindex{\end{multicols}} |
| 1309 |
\makeatother |
| 1310 |
%StartVisiblePreamble |
| 1311 |
\usepackage{makeidx}\makeindex |
| 1312 |
\usepackage{hvindex} |
| 1313 |
%StopVisiblePreamble |
| 1314 |
\begin{document} |
| 1315 |
Sort with xindex \verb|-l DE --config AU| |
| 1316 |
\Index{Österreich} \Index{Öresund} |
| 1317 |
\Index{Ostern} \Index{Ober} \Index{Oberin} |
| 1318 |
\Index{Österreich} \Index{Öresund} |
| 1319 |
\Index{Ödem} \Index{Oligarch} \Index{Oder} |
| 1320 |
\Index{Ostern} \Index{Ober} \Index{Oberin} |
| 1321 |
\Index{Obstler} \Index{Öl} \Index{ölen} |
| 1322 |
\Index{Oder|seealso{Fluss}} \Index{Göbel} |
| 1323 |
\Index{oder} \index{Fluss!Oder} |
| 1324 |
\Index{Goethe} \Index{Göthe} \Index{Götz} |
| 1325 |
\Index{Goldmann} |
| 1326 |
\printindex |
| 1327 |
\end{document} |
| 1328 |
\end{externalDocument} |
| 1329 |
|
| 1330 |
|
| 1331 |
Instad of using the options \Lkeyword{compiler}, \Lkeyword{biber}, and \Lkeyword{xindex} |
| 1332 |
one can also use only the optional argument \Lkeyword{runsequence} to define an individuell |
| 1333 |
sequence of commands, e.g.: |
| 1334 |
\begin{verbatim} |
| 1335 |
runsequence={lualatex,biber,{xindex -l de -c AU},lualatex,lualatex} |
| 1336 |
\end{verbatim} |
| 1337 |
|
| 1338 |
\begin{externalDocument}[ |
| 1339 |
grfOptions={width=0.30\linewidth}, |
| 1340 |
pages={1,2,3,4,5,6}, |
| 1341 |
pagesep=2pt, |
| 1342 |
frame, |
| 1343 |
runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, |
| 1344 |
verbose, |
| 1345 |
cleanup={log,aux,toc,bbl,blg}, |
| 1346 |
code,docType=latex, |
| 1347 |
lstOptions={columns=fixed}]{voss} |
| 1348 |
\documentclass[paper=a5,parskip=half-,DIV=12,fontsize=12pt]{scrbook} |
| 1349 |
%StartVisiblePreamble |
| 1350 |
\usepackage[ngerman]{babel} |
| 1351 |
\usepackage{libertinus,hvindex} |
| 1352 |
\usepackage{makeidx}\makeindex |
| 1353 |
\usepackage{biblatex}\addbibresource{biblatex-examples.bib} |
| 1354 |
%StopVisiblePreamble |
| 1355 |
\usepackage{blindtext} |
| 1356 |
\begin{document} |
| 1357 |
\blindtext |
| 1358 |
\Index{Österreich} \Index{Öresund} |
| 1359 |
\Index{Ostern} \Index{Ober} \Index{Oberin} |
| 1360 |
\Index{Österreich} \Index{Öresund} |
| 1361 |
\Index{Ödem} \Index{Oligarch} \Index{Oder} |
| 1362 |
\Index{Goldmann} |
| 1363 |
\printindex |
| 1364 |
\nocite{*}\printbibliography |
| 1365 |
\blindtext |
| 1366 |
\blinddocument |
| 1367 |
|
| 1368 |
\end{document} |
| 1369 |
\end{externalDocument} |
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
\subsection{Using \texttt{listings}} |
| 1377 |
The default is using \Lcs{lstinputlisting} for the printed code sequences. |
| 1378 |
|
| 1379 |
\begin{externalDocument}[ |
| 1380 |
grfOptions={width=0.45\linewidth}, |
| 1381 |
pages={1,3}, |
| 1382 |
frame,compiler=pdflatex, |
| 1383 |
% crop, |
| 1384 |
runs=2,code,docType=latex, |
| 1385 |
frame, |
| 1386 |
lstOptions={columns=fixed}]{voss} |
| 1387 |
%StartVisiblePreamble |
| 1388 |
\documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrbook} |
| 1389 |
\DeclareNewSectionCommand[ |
| 1390 |
style=section, |
| 1391 |
level=4, |
| 1392 |
beforeskip=-3.25ex plus -1ex minus -.2ex, |
| 1393 |
afterskip=1.5ex plus .2ex, |
| 1394 |
font=\normalsize, |
| 1395 |
indent=0pt, |
| 1396 |
counterwithin=subsubsection |
| 1397 |
]{subsubsubsection} |
| 1398 |
\RedeclareSectionCommand[ |
| 1399 |
level=5, |
| 1400 |
toclevel=5, |
| 1401 |
tocindent=13em, |
| 1402 |
tocnumwidth=5.9em, |
| 1403 |
counterwithin=subsubsubsection |
| 1404 |
]{paragraph} |
| 1405 |
\RedeclareSectionCommand[ |
| 1406 |
level=6, |
| 1407 |
toclevel=6, |
| 1408 |
tocindent=15em, |
| 1409 |
tocnumwidth=6.8em |
| 1410 |
]{subparagraph} |
| 1411 |
\setcounter{secnumdepth}{\subsubsubsectionnumdepth} |
| 1412 |
\setcounter{tocdepth}{\subsubsubsectiontocdepth} |
| 1413 |
%StopVisiblePreamble |
| 1414 |
\usepackage[ngerman]{babel} |
| 1415 |
\usepackage{libertinus} |
| 1416 |
\usepackage{blindtext} |
| 1417 |
\begin{document} |
| 1418 |
\tableofcontents |
| 1419 |
\chapter{Einführung} |
| 1420 |
\section{Ein Abschnitt} |
| 1421 |
\subsection{Ein Unterabschnitt} |
| 1422 |
\subsubsection{Ein Unter-Unterabschnitt} |
| 1423 |
\subsubsubsection{Ein Unter-Unter-Unterabschnitt} |
| 1424 |
\paragraph{Der normale Paragraph} |
| 1425 |
\blindtext |
| 1426 |
\subparagraph{Der normale Unterparagraph} |
| 1427 |
\blindtext |
| 1428 |
\blinddocument |
| 1429 |
\end{document} |
| 1430 |
\end{externalDocument} |
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
It also possible to use \Lcs{VerbatimInput} from package \Lpack{fancyvrb}. In general |
| 1435 |
it makes no difference using the optional argument \Lkeyword{usefancyvrb} or not. |
| 1436 |
|
| 1437 |
|
| 1438 |
\begin{externalDocument}[ |
| 1439 |
grfOptions={width=0.23\linewidth}, |
| 1440 |
pages={1,2,3,4},pagesep=1pt, |
| 1441 |
frame,compiler=pdflatex, |
| 1442 |
showFilename, |
| 1443 |
% crop, |
| 1444 |
runs=2,code,docType=latex, |
| 1445 |
frame,framesep=0pt,usefancyvrb]{voss} |
| 1446 |
%StartVisiblePreamble |
| 1447 |
\documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrbook} |
| 1448 |
\DeclareNewSectionCommand[ |
| 1449 |
style=section, |
| 1450 |
level=4, |
| 1451 |
beforeskip=-3.25ex plus -1ex minus -.2ex, |
| 1452 |
afterskip=1.5ex plus .2ex, |
| 1453 |
font=\normalsize, |
| 1454 |
indent=0pt, |
| 1455 |
counterwithin=subsubsection |
| 1456 |
]{subsubsubsection} |
| 1457 |
\RedeclareSectionCommand[ |
| 1458 |
level=5, |
| 1459 |
toclevel=5, |
| 1460 |
tocindent=13em, |
| 1461 |
tocnumwidth=5.9em, |
| 1462 |
counterwithin=subsubsubsection |
| 1463 |
]{paragraph} |
| 1464 |
\RedeclareSectionCommand[ |
| 1465 |
level=6, |
| 1466 |
toclevel=6, |
| 1467 |
tocindent=15em, |
| 1468 |
tocnumwidth=6.8em |
| 1469 |
]{subparagraph} |
| 1470 |
\setcounter{secnumdepth}{\subsubsubsectionnumdepth} |
| 1471 |
\setcounter{tocdepth}{\subsubsubsectiontocdepth} |
| 1472 |
%StopVisiblePreamble |
| 1473 |
\usepackage[ngerman]{babel} |
| 1474 |
\usepackage{libertinus} |
| 1475 |
\usepackage{blindtext} |
| 1476 |
\begin{document} |
| 1477 |
\tableofcontents |
| 1478 |
\chapter{Einführung} |
| 1479 |
\section{Ein Abschnitt} |
| 1480 |
\subsection{Ein Unterabschnitt} |
| 1481 |
\subsubsection{Ein Unter-Unterabschnitt} |
| 1482 |
\subsubsubsection{Ein Unter-Unter-Unterabschnitt} |
| 1483 |
\paragraph{Der normale Paragraph} |
| 1484 |
\blindtext |
| 1485 |
\subparagraph{Der normale Unterparagraph} |
| 1486 |
\blindtext |
| 1487 |
\blinddocument |
| 1488 |
\end{document} |
| 1489 |
\end{externalDocument} |
| 1490 |
|
| 1491 |
|
| 1492 |
%\clearpage |
| 1493 |
|
| 1494 |
|
| 1495 |
\subsection{Vertical space} |
| 1496 |
|
| 1497 |
\begin{verbatim} |
| 1498 |
\define@key{hv}{aboveskip}[\medskipamount]{% |
| 1499 |
\setlength\hv@extern@aboveskip{#1}} |
| 1500 |
\define@key{hv}{belowpreambleskip}[\smallskipamount]{% |
| 1501 |
\setlength\hv@extern@belowpreambleskip{#1}} |
| 1502 |
\define@key{hv}{belowbodyskip}[\smallskipamount]{% |
| 1503 |
\setlength\hv@extern@belowbodyskip{#1}} |
| 1504 |
\define@key{hv}{belowskip}[\medskipamount]{% |
| 1505 |
\setlength\hv@extern@belowskip{#1}} |
| 1506 |
\end{verbatim} |
| 1507 |
|
| 1508 |
\begin{description} |
| 1509 |
\item[\Lkeyword{aboveskip}] Vertical space \emph{before} the environment \Lenv{externalDocument} or |
| 1510 |
the command \Lcs{runExtCmd} (default \Lcs{medskipamount}) |
| 1511 |
\item[\Lkeyword{belowpreambleskip}] Vertical space between preamble and body (default \Lcs{smallskipamount}) |
| 1512 |
\item[\Lkeyword{belowbodyskip}] Vertical space between body and output (default \Lcs{smallskipamount}) |
| 1513 |
\item[\Lkeyword{belowskip}] Vertical space \emph{after} the environment \Lenv{externalDocument} or |
| 1514 |
the command \Lcs{runExtCmd} (default \Lcs{medskipamount}) |
| 1515 |
\end{description} |
| 1516 |
|
| 1517 |
|
| 1518 |
The listings environment uses its own keywords \Lkeyword{aboveskip} and \Lkeyword{belowskip}, also preset |
| 1519 |
to \Lcs{medskipamount}. These ones can be changed by using the keyword \Lkeyword{lstOptions}: |
| 1520 |
|
| 1521 |
\begin{verbatim} |
| 1522 |
..., lstOptions = {aboveskip=..., belowskip=...}, ... |
| 1523 |
\end{verbatim} |
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
\subsection{No output} |
| 1529 |
By default there is an image or text as output of the external run. In a case, where |
| 1530 |
you are only interested in the code, which should be formatted in the same style as |
| 1531 |
other examples, you can set \Lkeyword{showoutput} to false. |
| 1532 |
|
| 1533 |
|
| 1534 |
\begin{externalDocument}[ |
| 1535 |
showoutput=false, |
| 1536 |
frame,compiler=pdflatex, |
| 1537 |
crop, |
| 1538 |
runs=2,code,docType=latex, |
| 1539 |
frame,usefancyvrb]{voss} |
| 1540 |
%StartVisiblePreamble |
| 1541 |
\documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrbook} |
| 1542 |
\DeclareNewSectionCommand[ |
| 1543 |
style=section, |
| 1544 |
level=4, |
| 1545 |
beforeskip=-3.25ex plus -1ex minus -.2ex, |
| 1546 |
afterskip=1.5ex plus .2ex, |
| 1547 |
font=\normalsize, |
| 1548 |
indent=0pt, |
| 1549 |
counterwithin=subsubsection |
| 1550 |
]{subsubsubsection} |
| 1551 |
%StopVisiblePreamble |
| 1552 |
\RedeclareSectionCommand[ |
| 1553 |
level=5, |
| 1554 |
toclevel=5, |
| 1555 |
tocindent=13em, |
| 1556 |
tocnumwidth=5.9em, |
| 1557 |
counterwithin=subsubsubsection |
| 1558 |
]{paragraph} |
| 1559 |
\RedeclareSectionCommand[ |
| 1560 |
level=6, |
| 1561 |
toclevel=6, |
| 1562 |
tocindent=15em, |
| 1563 |
tocnumwidth=6.8em |
| 1564 |
]{subparagraph} |
| 1565 |
\setcounter{secnumdepth}{\subsubsubsectionnumdepth} |
| 1566 |
\setcounter{tocdepth}{\subsubsubsectiontocdepth} |
| 1567 |
\usepackage[ngerman]{babel} |
| 1568 |
\usepackage{libertinus} |
| 1569 |
\usepackage{blindtext} |
| 1570 |
\begin{document} |
| 1571 |
\tableofcontents |
| 1572 |
\chapter{Einführung} |
| 1573 |
\section{Ein Abschnitt} |
| 1574 |
\subsection{Ein Unterabschnitt} |
| 1575 |
\subsubsection{Ein Unter-Unterabschnitt} |
| 1576 |
\subsubsubsection{Ein Unter-Unter-Unterabschnitt} |
| 1577 |
\blindtext |
| 1578 |
\end{document} |
| 1579 |
\end{externalDocument} |
| 1580 |
|
| 1581 |
|
| 1582 |
%\clearpage%%%%%%%%%%%%%% |
| 1583 |
|
| 1584 |
\section{Defining new marker} |
| 1585 |
Suppose you do not want for a \LaTeX\ document the complete body part between \Lcs{begin} |
| 1586 |
and \Lcs{end} printed. In this case you can define own markers, e.g.: |
| 1587 |
|
| 1588 |
\begin{Verbatim}[fontsize=\small,label={New marker definition},fontfamily=tt] |
| 1589 |
\defMarkerType{ltx} |
| 1590 |
{\perCent StartVisibleBody} |
| 1591 |
{\perCent StopVisibleBody} |
| 1592 |
{\perCent StartVisiblePreamble} |
| 1593 |
{\perCent StopVisiblePreamble} |
| 1594 |
\end{Verbatim} |
| 1595 |
|
| 1596 |
Whith this definition and the setting \Lkeyset{docType=ltx} the last example looks like: |
| 1597 |
|
| 1598 |
|
| 1599 |
\defMarkerType{ltx} |
| 1600 |
{\perCent StartVisibleBody} |
| 1601 |
{\perCent StopVisibleBody} |
| 1602 |
{\perCent StartVisiblePreamble} |
| 1603 |
{\perCent StopVisiblePreamble} |
| 1604 |
|
| 1605 |
|
| 1606 |
\begin{externalDocument}[ |
| 1607 |
grfOptions={width=\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}, |
| 1608 |
% pages={1}, |
| 1609 |
crop, |
| 1610 |
% mpwidth=0.6\linewidth, |
| 1611 |
frame, |
| 1612 |
compiler=pdflatex, |
| 1613 |
showFilename, |
| 1614 |
runs=2,code,docType=ltx, |
| 1615 |
usefancyvrb]{voss} |
| 1616 |
\documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrreprt} |
| 1617 |
%StartVisiblePreamble |
| 1618 |
\DeclareNewSectionCommand[ |
| 1619 |
style=section, |
| 1620 |
level=4, |
| 1621 |
beforeskip=-3.25ex plus -1ex minus -.2ex, |
| 1622 |
afterskip=1.5ex plus .2ex, |
| 1623 |
font=\normalsize, |
| 1624 |
indent=0pt, |
| 1625 |
counterwithin=subsubsection |
| 1626 |
]{subsubsubsection} |
| 1627 |
%StopVisiblePreamble |
| 1628 |
\RedeclareSectionCommand[ |
| 1629 |
level=5, |
| 1630 |
toclevel=5, |
| 1631 |
tocindent=13em, |
| 1632 |
tocnumwidth=5.9em, |
| 1633 |
counterwithin=subsubsubsection |
| 1634 |
]{paragraph} |
| 1635 |
\RedeclareSectionCommand[ |
| 1636 |
level=6, |
| 1637 |
toclevel=6, |
| 1638 |
tocindent=15em, |
| 1639 |
tocnumwidth=6.8em |
| 1640 |
]{subparagraph} |
| 1641 |
\setcounter{secnumdepth}{\subsubsubsectionnumdepth} |
| 1642 |
\setcounter{tocdepth}{\subsubsubsectiontocdepth} |
| 1643 |
\usepackage[ngerman]{babel} |
| 1644 |
\usepackage{libertinus} |
| 1645 |
\usepackage{blindtext} |
| 1646 |
\makeatletter\let\ps@plain\ps@empty\makeatother |
| 1647 |
\begin{document} |
| 1648 |
\tableofcontents |
| 1649 |
\chapter{Einführung} |
| 1650 |
\section{Ein Abschnitt} |
| 1651 |
\subsection{Ein Unterabschnitt} |
| 1652 |
\subsubsection{Ein Unter-Unterabschnitt} |
| 1653 |
%StartVisibleBody |
| 1654 |
\subsubsubsection{Ein Unter-Unter-Unterabschnitt} |
| 1655 |
%StopVisibleBody |
| 1656 |
\blindtext |
| 1657 |
\end{document} |
| 1658 |
\end{externalDocument} |
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
\section{Supported engines} |
| 1664 |
\subsection{\MP\ example} |
| 1665 |
|
| 1666 |
Needs the run sequence setting to get a \texttt{pdf} from the created \texttt{dvi} output. |
| 1667 |
It is already internally defined. |
| 1668 |
|
| 1669 |
\begin{externalDocument}[ |
| 1670 |
% grfOptions={width=0.45\linewidth}, |
| 1671 |
% pages={1,3}, |
| 1672 |
frame, |
| 1673 |
verbose=false, |
| 1674 |
compiler=mpost, |
| 1675 |
showFilename, |
| 1676 |
% crop, |
| 1677 |
cleanup, |
| 1678 |
code, |
| 1679 |
docType=mp, |
| 1680 |
ext=mp,]{voss} |
| 1681 |
%StartVisiblePreamble |
| 1682 |
defaultfont:="ptmr8r"; |
| 1683 |
warningcheck:=0; |
| 1684 |
%StopVisiblePreamble |
| 1685 |
beginfig(1) |
| 1686 |
draw fullcircle shifted (0.5,0.6) xscaled 8cm yscaled 3.5cm |
| 1687 |
withpen pencircle scaled 5bp withcolor red; |
| 1688 |
special( " /Times-Roman findfont 150 scalefont setfont " & |
| 1689 |
" 0 10 moveto (MPost) false charpath clip stroke gsave 150 70 translate " & |
| 1690 |
" 2 4 600 {dup 0 moveto 0 exch 0 exch 0 360 arc stroke} for grestore "); |
| 1691 |
endfig; |
| 1692 |
end; |
| 1693 |
\end{externalDocument} |
| 1694 |
|
| 1695 |
For \MP\ exists an optional argument \Lkeyword{mposttex} which is preset |
| 1696 |
to \Lkeyval{tex}. If you want to run the \MP\ part with \LaTeX\ instead of |
| 1697 |
\TeX\ then use \texttt{mposttex=latex}. |
| 1698 |
|
| 1699 |
|
| 1700 |
\clearpage |
| 1701 |
|
| 1702 |
|
| 1703 |
\subsection{plain\TeX\ example} |
| 1704 |
|
| 1705 |
Needs the run sequence setting to get a \texttt{pdf} from the created \texttt{dvi} output. |
| 1706 |
It is already internally defined. |
| 1707 |
|
| 1708 |
|
| 1709 |
\begin{externalDocument}[ |
| 1710 |
grfOptions={width=0.5\linewidth}, |
| 1711 |
% pages={1,3}, |
| 1712 |
frame, |
| 1713 |
verbose=false, |
| 1714 |
compiler=tex, |
| 1715 |
showFilename, |
| 1716 |
% crop, |
| 1717 |
code, |
| 1718 |
docType=tex, |
| 1719 |
ext=tex,]{voss} |
| 1720 |
\magnification=\magstep1 |
| 1721 |
\baselineskip=12pt |
| 1722 |
\hsize=6.3truein |
| 1723 |
\vsize=8.7truein |
| 1724 |
\font\footsc=cmcsc10 at 8truept |
| 1725 |
\font\footbf=cmbx10 at 8truept |
| 1726 |
\font\footrm=cmr10 at 10truept |
| 1727 |
%StartVisiblePreamble |
| 1728 |
\footline={\footsc the electronic journal of combinatorics |
| 1729 |
{\footbf 16} (2009), \#R00\hfil\footrm\folio} |
| 1730 |
%StopVisiblePreamble |
| 1731 |
%StartBody |
| 1732 |
\font\bigrm=cmr12 at 14pt |
| 1733 |
\centerline{\bigrm An elementary proof of the reconstruction conjecture} |
| 1734 |
|
| 1735 |
\bigskip\bigskip |
| 1736 |
\centerline{D. Remifa\footnote*{Thanks to the editors of this journal!}} |
| 1737 |
\smallskip |
| 1738 |
\centerline{Department of Inconsequential Studies} |
| 1739 |
\centerline{Solatido College, North Kentucky, USA} |
| 1740 |
\centerline{\tt [email protected]} |
| 1741 |
\bigskip |
| 1742 |
\centerline{\footrm |
| 1743 |
Submitted: Jan 1, 2009; Accepted: Jan 2, 2009; Published: Jan 3, 2009} |
| 1744 |
\centerline{\footrm Mathematics Subject Classifications: 05C88, 05C89} |
| 1745 |
\bigskip\bigskip |
| 1746 |
\centerline{\bf Abstract} |
| 1747 |
\smallskip |
| 1748 |
{\narrower\noindent |
| 1749 |
The reconstruction conjecture states that the multiset of unlabeled |
| 1750 |
vertex-deleted subgraphs of a graph determines the graph, provided it |
| 1751 |
has at least 3 vertices. A version of the problem was first stated |
| 1752 |
by Stanis\l aw Ulam. In this paper, we show that the conjecture can |
| 1753 |
be proved by elementary methods. It is only necessary to integrate |
| 1754 |
the Lenkle potential of the Broglington manifold over the quantum |
| 1755 |
supervacillatory measure in order to reduce the set of possible |
| 1756 |
counterexamples to a small number (less than a trillion). A simple |
| 1757 |
computer program that implements Pipletti's classification theorem |
| 1758 |
for torsion-free Aramaic groups with simplectic socles can then |
| 1759 |
finish the remaining cases.} |
| 1760 |
|
| 1761 |
\bigskip |
| 1762 |
\beginsection 1. Introduction. |
| 1763 |
|
| 1764 |
This is the start of the introduction. |
| 1765 |
\bye |
| 1766 |
\end{externalDocument} |
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
\subsection{\LuaLaTeX\ example} |
| 1771 |
With Lua\LaTeX\ and and using PostScript code the intermediate GhostScript run is |
| 1772 |
not needed. The \texttt{pdf} is directly created. |
| 1773 |
|
| 1774 |
\begin{externalDocument}[ |
| 1775 |
grfOptions={width=0.5\linewidth}, |
| 1776 |
% pages={1,3}, |
| 1777 |
% frame, |
| 1778 |
verbose=false, |
| 1779 |
compiler=lualatex, |
| 1780 |
showFilename, |
| 1781 |
crop, |
| 1782 |
code, |
| 1783 |
docType=latex, |
| 1784 |
ext=tex,]{voss} |
| 1785 |
\documentclass{report} |
| 1786 |
\pagestyle{empty} |
| 1787 |
%StartVisiblePreamble |
| 1788 |
\usepackage{fontenc}\usepackage{libertinus} |
| 1789 |
\usepackage{pst-all} |
| 1790 |
%StopVisiblePreamble |
| 1791 |
\begin{document} |
| 1792 |
\psset{unit=0.8cm} |
| 1793 |
\begin{pspicture}(-9,-15)(9,2) |
| 1794 |
\psaxes(0,0)(-9,-15)(9,2) |
| 1795 |
\psplot[algebraic,plotstyle=curve,curvature=1 1 0, |
| 1796 |
linewidth=2pt,linecolor=red]{-8}{8}{ |
| 1797 |
1 - 3876218985722260225*x^2/10892114744073986176 |
| 1798 |
+ 14975974793271450625*x^4/174273835905183778816 |
| 1799 |
- 317095420958296875*x^6/26811359370028273664 |
| 1800 |
+ 194412970920703125*x^8/214490874960226189312 |
| 1801 |
- 2090988251953125*x^10/53622718740056547328 |
| 1802 |
+ 99480224609375*x^12/107245437480113094656 |
| 1803 |
- 7879638671875*x^14/697095343620735115264 |
| 1804 |
+ 152587890625*x^16/2788381374482940461056} |
| 1805 |
\end{pspicture} |
| 1806 |
\end{document} |
| 1807 |
\end{externalDocument} |
| 1808 |
|
| 1809 |
|
| 1810 |
\subsection{\ConTeXt\ example} |
| 1811 |
|
| 1812 |
|
| 1813 |
\begin{externalDocument}[ |
| 1814 |
grfOptions={width=0.31\linewidth}, |
| 1815 |
pages={1,2,3,4,5,6}, |
| 1816 |
pagesep=2pt, |
| 1817 |
frame, |
| 1818 |
framesep=0pt, |
| 1819 |
verbose=false, |
| 1820 |
compiler=context, |
| 1821 |
showFilename, |
| 1822 |
runs=2, |
| 1823 |
force, |
| 1824 |
code, |
| 1825 |
docType=context, |
| 1826 |
ext=tex,]{voss} |
| 1827 |
%StartVisiblePreamble |
| 1828 |
\definehead |
| 1829 |
[myhead] |
| 1830 |
[section] |
| 1831 |
\setuphead |
| 1832 |
[myhead] |
| 1833 |
[numberstyle=bold, |
| 1834 |
textstyle =bold, |
| 1835 |
before =\hairline\blank, |
| 1836 |
after =\nowhitespace\hairline] |
| 1837 |
%StopVisiblePreamble |
| 1838 |
\starttext |
| 1839 |
\startstandardmakeup |
| 1840 |
\midaligned{From Hasselt to America} |
| 1841 |
\midaligned{by} |
| 1842 |
\midaligned{J. Jonker and C. van Marle} |
| 1843 |
\stopstandardmakeup |
| 1844 |
\placecombinedlist[content] |
| 1845 |
\chapter{Introduction} |
| 1846 |
\input knuth \input knuth |
| 1847 |
\chapter[rensselaer]{The Rensselaer family} |
| 1848 |
\input knuth |
| 1849 |
\section{The first born} |
| 1850 |
\input knuth |
| 1851 |
\section{The early years} |
| 1852 |
... in those days Hasselt was ... |
| 1853 |
\input knuth |
| 1854 |
\section{Living and workin in America} |
| 1855 |
\input knuth |
| 1856 |
\chapter[lansing]{The Lansing family} |
| 1857 |
... the Lansing family was also ... |
| 1858 |
\input knuth |
| 1859 |
\chapter[cuyler]{The Cuyler family} |
| 1860 |
... much later Tydeman Cuyler ... |
| 1861 |
\input knuth |
| 1862 |
\myhead[headlines]{And the end of all} |
| 1863 |
foo |
| 1864 |
\stoptext |
| 1865 |
\end{externalDocument} |
| 1866 |
|
| 1867 |
|
| 1868 |
%\addtocontents{toc}{\protect\newpage} |
| 1869 |
|
| 1870 |
|
| 1871 |
\section{Running external commands} |
| 1872 |
Integrating the current directory of this document we can use the macro \Lcs{runExtCmd} with |
| 1873 |
the optional argument \Lkeyword{redirect} |
| 1874 |
|
| 1875 |
\begin{verbatim} |
| 1876 |
\runExtCmd[redirect]{ls -la}{voss} |
| 1877 |
\end{verbatim} |
| 1878 |
|
| 1879 |
to get the directory listed: |
| 1880 |
|
| 1881 |
\medskip |
| 1882 |
\runExtCmd[redirect,verbose]{ls -la}{voss} |
| 1883 |
|
| 1884 |
|
| 1885 |
\begin{verbatim} |
| 1886 |
\runExtCmd[redirect,verbose,lstOptions={basicstyle=\ttfamily\small}]{du}{voss}% *nix |
| 1887 |
\end{verbatim} |
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
\medskip |
| 1892 |
\runExtCmd[redirect,verbose,lstOptions={basicstyle=\ttfamily\small}]{du}{voss} |
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
\section{Other options} |
| 1899 |
|
| 1900 |
\begin{description} |
| 1901 |
\item[\Lkeyword{vshift}] A length for a vertical shift of the object, only valid for the inline mode. |
| 1902 |
See document source of example~\vpageref{inline-exa}. |
| 1903 |
%\item[\Lkeyword{outerFN}] Only valid for the twocolumn mode with onecolumn floats (environment \texttt{figure*}), |
| 1904 |
% to get the filename on the right or left of the whole page. |
| 1905 |
%\item[\Lkeyword{shiftFN}] A length to move the printed filename up or down. |
| 1906 |
\item[\Lkeyset{force=false}] can speed up the comiling time for the document. If a created image/output |
| 1907 |
already exists, there is no need to create it with the next run again and again. \emph This option is not valid |
| 1908 |
if the package option \Loption{checkCode} exists. |
| 1909 |
\item[\Lkeyword{cleanup}] the auxiliary files of a \LaTeX-run are deleted, preset to \texttt{aux}, \texttt{log}. |
| 1910 |
It must be a comma seperated list of the extensions of the main file, s.g. \texttt{cleanup=\{aux,log\}}. |
| 1911 |
\item[\Lkeyword{moveToExampleDir}] move all examples into a directory, must be set \emph{before} the |
| 1912 |
option \Lkeyword{ExampleDir}. |
| 1913 |
\item[\Lkeyword{ExampleDir}] name of a directory for the examples, must |
| 1914 |
first be created by the user himself. |
| 1915 |
\item[\Lkeyset{tcbox=false}] Can be used if there are some negative interactions between package \Lpack{listings} |
| 1916 |
and package \Lpack{tcolorbox}. |
| 1917 |
\item[\Lkeyword{framesep}] Value for \Lcs{fbox} if keyword \texttt{frame} is used. |
| 1918 |
\item[\Lkeyword{mpsep}] Distance between code and output (default 1\,em). |
| 1919 |
\item[\Lkeyword{pagesep}] Distance between pages for multipage output (default 1\,em). |
| 1920 |
\item[\Lkeyword{verbose}] Print control messages into the terminal and logfile. |
| 1921 |
\item[\Lkeyword{eps}] create an eps from the pdf (historical). |
| 1922 |
\end{description} |
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
\printindex |
| 1929 |
|
| 1930 |
|
| 1931 |
\end{document} |
| 1932 |
|
| 1933 |
|