Debian Codegraph @

texmf-dist/doc/latex/rvwrite/rvwrite-doc.tex

raw
1 %%
2 %%
3 %% This is file 'rvwrite-doc.tex'.
4 %%
5 %% File: rvwrite.sty Copyright (c) 2010 C. V. Radhakrishnan
6 %% River Valley, Mepukada, Malayinkil, Trivandrum 695571
7 %% http://www.river-valley.com Email: <[email protected]>
8 %%
9 %% This package may be distributed under the terms of the LaTeX Project
10 %% Public License, as described in lppl.txt in the base LaTeX distribution.
11 %% Either version 1.0 or, at your option, any later version.
12 %%
13 %% $Id: rvwrite-doc.tex,v 1.1 2010/08/27 09:43:57 cvr Exp cvr $
14 %%
15 %%
16
17 \documentclass[a4paper]{article}
18
19 \makeatletter
20 \usepackage[dvipsnames,svgnames]{xcolor}
21
22 \colorlet{itemcolor}{brown}
23 \colorlet{verbcolor}{Sepia}
24 \colorlet{botrulecolor}{orange!25}
25 \colorlet{botbgcolor}{orange!15}
26 \colorlet{botcolor}{orange!80}
27 \colorlet{pgrulecolor}{orange}
28 \colorlet{pgbgcolor}{white}
29
30 \colorlet{quicklinkrulecolor}{orange!40}
31 \colorlet{quicklinkcolor}{brown}
32 \colorlet{topverticalrule}{brown}
33 \colorlet{titlecolor}{brown}
34 \colorlet{hlinkcolor}{brown}
35 \colorlet{hlinktricolor}{orange!70}
36 \colorlet{linkcolor}{brown}
37 \colorlet{urlcolor}{brown}
38
39 \colorlet{arrayrulecolor}{olive!30}
40 \colorlet{seccolor}{brown}
41
42 \colorlet{toprulecolor}{orange!30}
43 \colorlet{topbgcolor}{orange!10}
44 \colorlet{topcolor}{brown!80}
45 %
46 %
47 \def\floatpagefraction{.99}
48 \usepackage{geometry}
49 \geometry{top=2in,
50 bottom=1in,
51 left=2in,
52 right=1in,
53 a4paper}
54
55 \DeclareRobustCommand{\LaTeX}{L\kern-.25em%
56 {\sbox\z@ T%
57 \vbox to\ht\z@{%
58 \hbox{%
59 \check@mathfonts
60 \fontsize\sf@size\z@
61 \math@fontsfalse\selectfont
62 A}%
63 \vss}%
64 }%
65 \kern-.10em%
66 \TeX}
67
68 \usepackage{comment,xspace}
69 \def\xml{\textsc{xml}\xspace}
70 \def\latex{\LaTeX\xspace}
71 \def\pdf{\textsc{pdf}\xspace}
72 \def\pdfa{\textsc{pdf/a-1}b\xspace}
73 \def\pdfx{\textsc{pdf/x-1}a\xspace}
74 \def\xmp{\textsc{xmp}\xspace}
75 \def\pdftex{\textsc{pdf\TeX}\xspace}
76 \def\defmacro#1{\texttt{\bsl#1}}
77 \def\thanh{H\`an Th\^e Th\`anh\xspace}
78 \def\gnulinux{\textsc{gnu/linux}\xspace}
79 \def\bsl{\expandafter\@gobble\string\\}
80
81 \let\@DRAFTout@Hook\@empty
82 \newcommand{\DRAFTout}{\g@addto@macro\@DRAFTout@Hook}
83 \newcommand{\@DRAFTout@Out}{%
84 \afterassignment\@DRAFTout@Test
85 \global\setbox\@cclv= %
86 }
87 \newcommand{\@DRAFTout@Test}{%
88 \ifvoid\@cclv\relax
89 \aftergroup\@DRAFTout@Output
90 \else
91 \@DRAFTout@Output
92 \fi%
93 }
94 \newcommand{\@DRAFTout@Output}{%
95 \@DRAFTout@Hook%
96 \@DRAFTout@Org@Out\box\@cclv%
97 }
98 \newcommand{\@DRAFTout@Org@Out}{}
99 \newcommand*{\@DRAFTout@Init}{%
100 \let\@DRAFTout@Org@Out\shipout
101 \let\shipout\@DRAFTout@Out
102 }
103 \newdimen\OHeight
104 \setlength\OHeight{\textheight}
105 \addtolength\OHeight{\headheight}
106 \addtolength\OHeight{\headsep}
107 \addtolength\OHeight{\footskip}
108
109 \newif\ifoverlay\overlayfalse
110
111 \AtBeginDocument{\@DRAFTout@Init}
112 \newcommand{\@DraftOverlay@Hook}{}
113 \newcommand{\AddToDraftOverlay}{\g@addto@macro\@DraftOverlay@Hook}
114 \newcommand{\ClearDraftOverlay}{\let\@DraftOverlay@Hook\@empty}
115 \newcommand{\@DraftOverlay}{%
116 \ifx\@DraftOverlay@Hook\@empty
117 \else
118 \bgroup
119 \@tempdima=1in
120 \@tempcnta=\@tempdima
121 \@tempcntb=-\@tempdima
122 \advance\@tempcntb\paperheight
123 \ifoverlay
124 \global\setbox\@cclv\vbox{%
125 \box\@cclv
126 \vbox{\let\protect\relax%
127 \unitlength=1pt%
128 \pictur@(0,0)(\strip@pt\@tempdima,\strip@pt\@tempdimb)%
129 \@DraftOverlay@Hook%
130 \endpicture}}%
131 \else
132 \global\setbox\@cclv\vbox{%
133 \vbox{\let\protect\relax%
134 \unitlength=1sp%
135 \pictur@(0,0)(\@tempcnta,\@tempcntb)%
136 \@DraftOverlay@Hook%
137 \endpicture}%
138 \box\@cclv}%
139 \fi
140 \egroup
141 \fi
142 }
143
144 \definecolor{gray30}{gray}{.7}
145 \definecolor{gray20}{gray}{.8}
146 \definecolor{gray10}{gray}{.9}
147
148 \DRAFTout{\@DraftOverlay}
149 \long\def\puttext(#1)#2{\AddToDraftOverlay{%
150 \setlength{\unitlength}{1pt}\thinlines%
151 \put(#1){#2}}}
152
153 \RequirePackage{shortvrb}
154 \MakeShortVerb{\|}
155 \RequirePackage{amsfonts,amssymb}
156 \IfFileExists{pxfonts.sty}{\RequirePackage{pxfonts}}{}
157 \IfFileExists{charter.sty}{\RequirePackage{charter}}{}
158 \IfFileExists{lfr.sty}{\RequirePackage[scaled=.85]{lfr}}{}
159 \IfFileExists{prima.sty}{\RequirePackage[scaled=.8]{prima}}{}
160
161 \def\theCodelineNo{\reset@font\tiny\arabic{CodelineNo}}
162
163 \def\@seccntformat#1{\llap{\csname the#1\endcsname.\hspace*{6pt}}}
164 \def\section{\@startsection {section}{1}{\z@}%
165 {-3.5ex \@plus -1ex \@minus -.2ex}%
166 {2.3ex \@plus.2ex}%
167 {\normalfont\large\bfseries\color{seccolor}}}
168 \def\subsection{\@startsection{subsection}{2}{\z@}%
169 {-2.25ex\@plus -1ex \@minus -.2ex}%
170 {1.5ex \@plus .2ex}%
171 {\normalfont\normalsize\bfseries\color{seccolor}}}
172 \def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
173 {-1.25ex\@plus -1ex \@minus -.2ex}%
174 {1.5ex \@plus .2ex}%
175 {\normalfont\normalsize\bfseries\color{seccolor}}}
176
177 \puttext(0,36){\botstring}%
178 \puttext(0,840){\copy\topbox}
179
180 \RequirePackage{colortbl}
181 \arrayrulecolor{arrayrulecolor}
182 \let\shline\hline
183 \def\hline{\noalign{\vskip3pt}\shline\noalign{\vskip4pt}}
184
185 \RequirePackage[pdftex,colorlinks]{hyperref}
186 \def\Hlink#1#2{\hyperlink{#2}{\color{hlinktricolor}%
187 $\blacktriangleright$~\color{hlinkcolor}#1}}
188 \def\@linkcolor{linkcolor}
189 \def\@urlcolor{urlcolor}
190
191 \pagestyle{empty}
192 \def\version#1{\gdef\@version{#1}}
193 \def\@version{1.0}
194 \def\contact#1{\gdef\@contact{#1}}
195 \def\author#1{\gdef\@author{#1}}
196 \def\@author{River Valley Technologies}
197 \def\@contact{\texttt{[email protected]}}
198 \def\keywords#1{\gdef\@keywords{#1}}
199 \def\@keywords{\LaTeX, \xml}
200
201 \long\def\Hrule{\\[-4pt]\hspace*{-3em}%
202 {\color{quicklinkrulecolor}\rule{\linewidth}{.1pt}}\\}
203
204 \long\def\dtxmarkone[#1][#2]#3#4#5{\def\next{#1}%
205 \ifcase\next\or\Hlink{#4}{#3}\Hrule \fi}
206
207 \newcounter{dtx}
208
209 \long\def\dtxmarktwo[#1][#2]#3#4#5{\def\next{#1}%
210 \stepcounter{dtx}\parbox{.45\linewidth}%
211 {\ifcase\next\or\Hlink{#4}{#3}\fi}%
212 \ifodd\thedtx\relax\else\Hrule\fi}
213
214 \let\dtxmark\dtxmarkone
215 \newbox\topbox
216 \long\def\maketitle{\global\setbox\topbox=\vbox{\hsize=\paperwidth
217 \parindent=0pt
218 \fcolorbox{toprulecolor}{topbgcolor}%
219 {\parbox[t][1.5in][c]{\paperwidth}%
220 {\hspace*{15mm}%
221 \parbox[c]{.35\paperwidth}{\fontsize{18pt}{20pt}%
222 \raggedright\normalfont\sffamily \selectfont
223 \color{titlecolor} \@title\\[6pt]
224 {\normalsize\rmfamily\scshape\@author}\\%
225 {\footnotesize\textsc{keywords:} \@keywords}}%
226 \hfill
227 \parbox[c][1.5in][c]{1mm}{\color{topverticalrule}%
228 \rule{.1pt}{1.5in}}%
229 \hfill
230 \parbox[c][1.5in][c]{.35\paperwidth}%
231 {\normalfont\footnotesize\sffamily\color{quicklinkcolor}%
232 \vspace*{6pt} QUICK LINKS\Hrule
233 \IfFileExists{tmp.out}{\input tmp.out}{}%
234 }\hspace*{5mm}%
235 }%
236 }%
237 }%
238 }
239 \gdef\botstring{\fcolorbox{botrulecolor}{botbgcolor}%
240 {\parbox[t][.5in][t]{\paperwidth}%
241 {\normalfont\sffamily\footnotesize%
242 \color{botcolor}%
243 \hspace*{5mm}\parbox[c][.5in][c]{.45\paperwidth}%
244 {\raggedright River Valley Technologies,
245 \href{http://www.river-valley.com}{%
246 http://www.river-valley.com}\\
247 River Valley Campus, Malayinkil, Trivandrum
248 695571, India\\ 9, Browns Court, Kennford,
249 Exeter, United Kingdom {\scshape ex6 7xy}
250 }\hfill%
251 \parbox[c][.5in][c]{1cm}
252 {\centering\sffamily\mdseries
253 \fcolorbox{pgrulecolor}{pgbgcolor}{\thepage}%
254 }\hfill
255 \parbox[c][.5in][c]{.45\paperwidth}
256 {\raggedleft\begin{tabular}{rl}%
257 Version:&\@version\\
258 Date:&\@date\\
259 Contact:&\@contact
260 \end{tabular}\hspace*{5mm}%
261 }%
262 }%
263 }%
264 }
265
266 \RequirePackage{enumitem}
267 \setitemize[1]{label={\small\color{itemcolor}$\blacktriangleright$},itemsep=0pt}
268 \setitemize[2]{label={\small\color{itemcolor}$\triangleright$},itemsep=0pt}
269 \setenumerate[1]{label={\small\color{itemcolor}\arabic*.},itemsep=0pt}
270
271 \def\MacroFont{\fontencoding\encodingdefault
272 \fontfamily\ttdefault
273 \fontseries\mddefault
274 \fontshape\updefault
275 \color{verbcolor}\small}%
276
277 \def\verbatim@font{\normalfont\color{verbcolor}\ttfamily}
278
279 \def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
280 \bgroup
281 \verb@eol@error \let\do\@makeother \dospecials
282 \verbatim@font\@noligs
283 \@ifstar\@sverb\@verb}
284
285 \makeatother
286
287 \begin{document}
288
289 \title{Enhancing \texttt{write} register in \LaTeX{} documents}
290 \date{2010/08/25}
291 \version{1.2}
292 \keywords{\pdf, pdf\TeX, \LaTeX}
293 \author{c.\,v.\,radhakrishnan}
294 \contact{\texttt{[email protected]}}
295
296 \maketitle
297
298 \section{Prolog}
299
300 The \verb+io+ registers in \TeX{} are often a matter of severe
301 limitation. When we try to typeset a document that loads a lot of
302 packages, it becomes a non-trivial task to satisfy register
303 requirements of various packages that compete with each other. It is
304 further complicated, if refining the typeset copy involves usage of
305 more custom packages which want to write out a few streams for reading
306 during subsequent \TeX{} compilations. \LaTeX{} needs a few registers
307 by default, some of the packages might need a few more streams thereby
308 reducing the available number of registers to less than ten. At times,
309 we have been forced to comment out a few \verb+write+ registers which
310 are seemingly unused for the document in question to make available
311 necessary registers for our custom packages. But, this is not an
312 elegant way, also, it requires developer intervention during the
313 production process. The package namely, \verb+rvwrite.sty+, is written
314 to solve this nagging problem.
315
316 \section{The theory}
317
318 We make use of only one register to write out all our streams,
319 meaning, all the items of information will be written to one file with
320 necessary mark-up and delimiters to separate at a latter stage. The
321 final separation and write out process depend on the literate
322 programming method developed by
323 \href{http://tug.org/interviews/gurari.pdf}{Eitan Gurari} and as
324 provided in his package, \verb+ProTex.sty+ which is part of any
325 standard \TeX{} distribution. The written out file is further
326 processed by \TeX{} with the help of \verb+ProTex.sty+ to segregate
327 all information and collect in separate files for our final usage.
328
329 \section{The implementation}
330
331 The process involves the following stages:
332 \begin{enumerate}
333 \item Mark-up all strings to be written out with special tags.
334 \item Run \LaTeX{} in the usual way which will generate
335 \verb+\jobname-write.tex+ along with other auxiliary files.
336 \item Typeset \verb+\jobname-write.tex+ with \LaTeX, this will result
337 in several output files as you would expect.
338 \end{enumerate}
339
340 \subsection{New functions}
341 \begin{description}
342 \item[\defmacro{newrvwrite}] Every new stream has to be initialized with
343 this function. eg.,
344 \begin{verbatim}
345 \newrvwrite{mex}
346 \end{verbatim}
347 \noindent This will facilitate a new auxiliary stream, \verb+\jobname-mex.tex+.
348 \item[\defmacro{rvwrite}] Macro to mark-up strings meant for writing
349 out. This has two arguments, first being the file type and the
350 second the strings. eg.,
351 \begin{verbatim}
352 \rvwrite{mex}{$\beta$}
353 \end{verbatim}
354 \noindent will write \verb+$\beta$+ to \verb+\jobname-mex.tex+ without
355 expanding any of the strings even if control sequence.
356 \item[\defmacro{ervwrite}] Macro to mark-up strings that contain
357 \TeX{} control sequences which need to be expanded before writing.
358 eg.,
359 \begin{verbatim}
360 \ervwrite{mex}{Section: \thesection}
361 \end{verbatim}
362 \noindent will write the contents after expanding \verb+\thesection+ to the
363 corresponding counter number.
364 \end{description}
365
366 \subsection{The usage}
367
368 Package can be loaded with the following command:
369 \begin{verbatim}
370 \usepackage{rvwrite}
371 \end{verbatim}
372 \noindent
373 There are no extra options for the package, nor is there any specific
374 sequence for loading, it can be loaded anywhere in the preamble.
375
376 As explained in the previous section, to define a new output stream,
377 \verb+\newrvwrite+ shall be used, the usage is provided below:
378 \begin{verbatim}
379 \newrvwrite{info}
380 \end{verbatim}
381 This command will finally result in a file, \verb+\jobname-info.tex+
382 which may be used as such or renamed to suit user's requirements. Each
383 stream may be initialized with \verb+\newrvwrite+ macros to facilitate
384 safe writing of output at the end of the process. Even if you miss to
385 initialize, the first instance of writing will trigger initialization,
386 but it will be more safer to initialize the stream in the beginning.
387
388 \subsection{Examples}
389
390 \subsubsection{Source file}
391
392 Given below is the source of a test file, \verb+test.tex+ for favor
393 of your testing:
394 \begin{verbatim}
395 \documentclass[a4paper]{article}
396 \usepackage{pxfonts}
397 \usepackage{rvwrite}
398 \usepackage{lipsum}
399
400 \begin{document}
401
402 \lipsum[1]
403 \newrvwrite{info}
404 \ervwrite{info}{\dlrchr\string\gamma\dlrchr}
405 \rvwrite{info}{$\beta$}
406 \ervwrite{info}{JOB: \jobname-\thepage}
407
408 \newrvwrite{tbl}
409 \ervwrite{tbl}{\string\def\string\thetable{9}}
410 \rvwrite{tbl}{{\itshape Indian \TeX\ Users Group}}
411 \rvwrite{tbl}{\LaTeX is a macro package written in \TeX\ language}
412 \lipsum[2]
413
414 \end{document}
415 \end{verbatim}
416
417 \subsubsection{Composite stream}
418
419 The verbatim source of the composite stream written to
420 \verb+test-write.tex+ is given below:
421 \begin{verbatim}
422 \documentclass{article}
423 \input ProTex.sty
424 \AlProTex{tex,<<<>>>,list,title,|,[]}
425 \begin{document}
426
427 \<test-info\><<<
428 $\gamma$
429 >>>
430 \<test-info\><<<
431 $\beta $
432 >>>
433 \<test-info\><<<
434 JOB: test-1
435 >>>
436 \<test-tbl\><<<
437 \def\thetable{9}
438 >>>
439 \<test-tbl\><<<
440 {\itshape Indian \TeX \ Users Group}
441 >>>
442 \<test-tbl\><<<
443 \LaTeX is a macro package written in \TeX \ language
444 >>>
445 \OutputCode\<test-info\>
446 \OutputCode\<test-tbl\>
447
448 \end{document}
449 \end{verbatim}
450
451 \subsubsection{Various output files}
452
453 Two files will be created (1) \verb+test-info.tex+ and (2)
454 \verb+test-tbl.tex+, the sources are provided below:
455
456 \paragraph{test-info.tex}
457 \begin{verbatim}
458 $\gamma$
459 $\beta $
460 JOB: test-1
461 \end{verbatim}
462
463 \paragraph{test-tbl.tex}
464 \begin{verbatim}
465 \def\thetable{9}
466 {\itshape Indian \TeX \ Users Group}
467 \LaTeX is a macro package written in \TeX \ language
468 \end{verbatim}
469
470 \section{Download}
471
472 The package, documentation and test files can be downloaded from the
473 \textsc{url}:\par\medskip
474 \url{http://download.river-valley.com/cvr/rvwrite.tar.gz}
475
476 \medskip
477 Bugs, suggestions and feature requests may be posted at
478 \href{http://www.cvr.cc/write-registers-in-tex/}{http://www.cvr.cc}.
479
480 \end{document}