Debian Codegraph @

texmf-dist/doc/latex/mathspic/grabtexdata.tex

raw
1 %% grabtexdata.tex
2 %% part of the mathsPIC package
3 %% example file used in Chapter 8 of the mathsPICmanual
4 %% (accessing TeX parameter values)
5 %% RWD Nickalls (c) April 2010
6 %% [email protected]
7 %%========================================================
8 %% for extracting TeX-file data into mathspic var commands
9 %%========================================================
10 \scrollmode % prevent LaTeX stopping if there are errors
11 %---------------------
12 % make a print command macro
13 \newcommand{\print}[1]{\immediate\write\outfile{#1}}
14 %---------------------
15 % make a comment % command macro
16 % first need to define percentchar for the write statement
17 % (From "TeX for the Impatient" (1990), p 292)
18 {\catcode`\%=12 \global\def\percentchar{%}}%
19 \newcommand{\comment}{\percentchar\space}
20 %
21 % make a \macro command --> %def<space>
22 \newcommand{\mydef}{def}
23 \newcommand{\macro}{\percentchar\mydef\space}
24 %----------------------
25 % create and open a new file with filename = textfiledata.dat
26 \newwrite\outfile
27 \immediate\openout\outfile=texfiledata.dat
28 %----------------------
29 %% write file header & general info
30 \print{\percentchar\percentchar\space file: texdata.dat}
31 \print{\percentchar\percentchar\space accessing TeX parameter values}
32 %---------------------
33 %% now get \textwidth and \textheight values from the tex file
34 \print{\comment ============}
35 \print{var w555 = \number\textwidth\comment\textwidth=scaled points}
36 \print{var w556 = \number\textwidth\comment\textwidth=\the\textwidth}
37 \print{var w557 = \number\textwidth/1864679.8\comment (\textwidth in cms)}
38 \print{\macro textwidthcms()\number\textwidth/1864679.8\comment}
39 \print{\macro textheightcms()\number\textheight/1864679.8\comment}
40 \print{\comment ============}
41 %--------------------
42 % close the file
43 \immediate\closeout\outfile
44 %%=========end=========================