Debian Codegraph @

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

raw
1 \RequirePackage{etex}
2 \documentclass[11pt,a4paper,oldfontcommands,danish,english,article,oneside]{memoir}
3 \usepackage[T1]{fontenc}
4 \usepackage[widespace]{fourier}
5 \DeclareRobustCommand{\SetFourierSpace}{%
6 \fontdimen2\font=1.13\fontdimen2\font}
7
8 \setlxvchars[\normalfont]
9
10 \settypeblocksize{*}{1.3\lxvchars}{1.618}
11
12 \usepackage{babel}
13
14 % for print
15 \setlrmargins{*}{*}{1.6}
16 \setulmargins{*}{*}{1.3}
17
18 % for online
19 \setlrmargins{*}{*}{0.7}
20 \setulmargins{*}{*}{1}
21 \setlength\marginparwidth{2.4cm}
22
23 \checkandfixthelayout
24
25 %\usepackage{felinepreamble}
26 %\usepackage{felinemarkup}
27
28
29 \usepackage[loadsampleconfig]{dlfltxbmarkup}
30 \usepackage{dlfltxbmisc,color}
31 \let\MarkWMargin=\felineWriteInMargin
32 \definecolor{nicered}{rgb}{.647,.129,.149}
33
34 \makeatletter
35 \renewcommand\feline@MWM@inner[1]{%
36 \parbox[t]{\marginparwidth}{%
37 \leavevmode\checkoddpage%
38 \ifoddpage\RaggedLeft\else\RaggedLeft\fi%
39 {\slshape\footnotesize\hspace{0pt}\color{nicered}#1\par}}}
40
41 \makeatother
42 \setsecheadstyle{\Large\bfseries\raggedright\color{nicered}}
43 \setsubsecheadstyle{\large\bfseries\raggedright\color{nicered}}
44
45
46 \reversemarginpar
47 %\twocolumnfootnotes
48
49 \setsecnumdepth{part}
50
51 \pagestyle{plain}
52
53 \begin{document}
54
55 \title{The \textsf{verbatimcopy} package\thanks{Version 0.06}}
56 \author{Lars Madsen\thanks{Email: [email protected] (packing and user docs)}
57 \and Ulrich Diez\thanks{Email: eu\[email protected] (macro coding)}
58 }
59 \maketitle
60
61 \section{Intro}
62
63 The \textsf{\jobname} package is a package that enables \LaTeX\ to
64 make verbatim copies of files. Additionally one can specify which
65 (sub)directory to save the copy in.
66
67 \textcolor{nicered}{\itshape\bfseries Please note that this version is
68 not backwards compatible! As \markup[nomk]{VerbatimCopy} now can
69 handle a \cs{verb}-like syntax, it can no longer be used inside other
70 macros. Though we do provide a compatability mode that reverts back to
71 the old functionality. See the \emph{Compatability} section for more
72 information.
73 }
74 \section{Usage}
75
76
77 The package provides two macros. Firstly the
78 \begin{syntax}
79 \markup{setOutputDir}\marg{dir}
80 \end{syntax}
81 macro is used for specifying which default directory to copy files to.
82 \markup[nomk]{setOutputDir} will automatically add a trailing
83 >>\texttt{/}<< if missing.
84 On systems that are not able to use >>\texttt{/}<< as a directory
85 delimiter, please redefine \markup[nomk]{VC@slash}
86 accordingly.\footnote{As we do not have access to systems where this
87 is needed this features has not been throughly tested.}
88 The default output directory is the current directory. Please note
89 that we cannot create directories, the directory specified has to
90 exist beforehand.
91
92
93 The main macro of the package is
94 \begin{syntax}
95 \markup{VerbatimCopy}\marg{input file}\marg{output file}
96 \end{syntax}
97 which will take a verbatim copy of \Arg{input file} and save it as
98 \Arg{output file}. \textit{Note:} If \Arg{output file} does not have
99 an extension, then \LaTeX\ gives it >>\texttt{.tex}<<.
100
101 Be very careful when using this package, it will overwrite the target
102 file without warning.
103
104 \section{Advanced usage}
105 \label{sec:advanced-usage}
106
107
108
109 Actually both \markup[nomk]{setOutputDir} and
110 \markup[nomk]{VerbatimCopy} supports a more \markup[nomk]{verb}-like
111 syntax. That is you can use a syntax similar to
112 \begin{syntax}
113 \markup[nomk]{setOutputDir}\Arg{char}\Arg{some name not containing \textsf{char}}\Arg{char}
114 \end{syntax}
115 example
116 \begin{syntax}
117 \verb+\setOutputDir|# #{@} b&~ $$/|+
118 \end{syntax}
119 for the already existing dir >>\verb+# #{@} b&~ $$+<<, meaning
120 that we can use directories with special names. Any linebreak in
121 the directory name or in the input or output names for
122 \markup[nomk]{VerbatimCopy} are silently ignored, but the spaces
123 do count. Many editors automatically strip spaces at
124 line-endings, thus avoiding linebreaks after spaces might be a
125 good idea.
126
127 With \markup[nomk]{VerbatimCopy} you will need two sets of \Arg{char}
128 characters (to replace the braces in the syntax above) and these sets
129 need not be the same. Example:
130 \begin{syntax}
131 \verb|\VerbatimCopy#test.tex#+test%#2}.tex+|
132 \end{syntax}
133 meaning that the file >>\texttt{test\%\#2\}.tex}<< will be a
134 verbatim copy of the original file >>\texttt{test.tex}<<.
135
136 \subsection{A note about spaces in filenames}
137 \label{sec:note-about-spaces}
138
139 Heiko Oberdiek mentions in his \markup[sty,nomk]{grffile} package:
140 \begin{quote}\itshape
141 In general it is not possible to use space inside file names,
142 because \TeX\ considers the space character as termination in its
143 syntax for commands that expect a file name.
144 \end{quote}
145 But in most modern \LaTeX\ distributions one can use double
146 quotes around the filename containing spaces. If you use
147 \begin{syntax}
148 \verb+\usepackage[enquotefilenames]{verbatimcopy}+
149 \end{syntax}
150 file-paths will get wrapped into double-quotes automatically
151 and you can avoid doing this ``by hand'' for the sake of avoiding
152 issues which might come from string-concatenation of
153 \markup[nomk]{setOutputDir}'s \Arg{dir} and
154 \markup[nomk]{VerbatimCopy}'s \Arg{output file}.
155
156 On systems that allow/require a different file-name-delimiter,
157 redefine \markup[nomk]{VC@quote} accordingly.
158
159 \subsection{Compatability}
160 \label{sec:compatability}
161
162 As mentioned ealier the macros \markup[nomk]{VerbatimCopy} and
163 \markup[nomk]{setOutputDir} have been changed to allow a
164 \cs{verb}-like functionality. This also means that
165 \cs{VerbatimCopy} and \cs{setOutputDir} can no longer be used
166 inside other macros. Some people might be able to live without
167 the \cs{verb}-like features and would like to be able to use
168 \cs{VerbatimCopy} and \cs{setOutputDir} inside other macros.
169 These users have two possibilities:
170 \begin{syntax}
171 \verb+\usepackage[compatibility]{verbatimcopy}+
172 \end{syntax}
173 or
174 \begin{syntax}
175 \cs{OldVerbatimCopy}
176 \end{syntax}
177 \begin{syntax}
178 \cs{OldsetOutputDir}
179 \end{syntax}
180 (which is always available). Just note that using the `old'
181 macros you cannot have special characters in the filenames, but
182 spaces are still allowed using the syntax shown ealier (using
183 double quotes).
184
185 \section{A hint for programmers}
186 \label{sec:hint-programmers}
187
188 As mentioned earlier \markup[nomk]{VerbatimCopy} can no longer be used,
189 as is, inside other macros. For that you will need a trick. Here is
190 what Ulrich Diez provided such that this version of
191 \markup[sty,nomk]{verbatimcopy} works with my LaTeX-book:
192 \begingroup
193 \footnotesize
194 \begin{verbatim}
195 \makeatletter
196 % helper macro
197 \newcommand\VCverbdef[1]{%
198 \VCverbaction{\expandafter\newcommand
199 \expandafter*\expandafter
200 #1\@firstofone}{}%
201 }%
202 %
203 % use this incase you use odd input or output filenames
204 \VCverbdef\felineFC@input|input with odd letter.tex|
205 \VCverbdef\felineFC@output+output+
206 % I use 'feline' for localisation in some internal macros
207 \newcommand\feline@run@verbatimcopy{%
208 \@bsphack
209 \begingroup
210 \edef\@tempa{%
211 \endgroup
212 \noexpand\scantokens{%
213 \begingroup
214 \noexpand\csname VerbatimCopy\endcsname
215 "\felineFC@input""\felineFC@output"%
216 %\scantokens will produce a trailing space without this:
217 \endlinechar=-1
218 }%
219 \endgroup
220 \@esphack
221 }\@tempa
222 }
223 \end{verbatim}
224 \endgroup
225
226 \section{Acknowledgement}
227
228 The main idea behind this package was originally posted on
229 \texttt{comp.text.tex} by Ulrich Diez
230 (\url{http://groups.google.com/group/comp.text.tex/msg/153e3dc7a8d0e548?hl=en}).
231 The idea is to use a simple, local, redefinition of
232 \markup[nomk]{verbatiminput}, which, instead of writing the contents
233 in the document, just writes it to another file.
234
235 Later Ulrich Diez provided new code that extends the original to
236 macros. This is the code that are currently in the \texttt{\jobname}
237 package, completely replacing the old code.
238
239 The \textsf{\jobname} package automatically loads the
240 \markup[nomk,sty]{verbatim} package.
241
242
243 \section{Why?}
244 \label{sec:why}
245
246 One might ask why the need for a functionality like this?
247
248 Here is where I use it: In my Danish 400+ pages \LaTeX\ book
249 (\url{http://www.imf.au.dk/system/latex/bog}), I have lots of
250 examples. For many of these examples I'd like to offer the source for
251 download (as was done for the \LaTeX\ Companion, 2nd edition). Several
252 examples are created using autogenerated fully compilable files that
253 are converted into EPS/PDF and included as graphics. All of my
254 examples are of course numbered, but the actual files that make up the
255 external files are all individually named. To make it easier for users
256 to find the right code, the downloadable source files are named to fit
257 the example numbers in the book. So instead of writing a script to
258 rename files, we simply let \LaTeX\ do the verbatim copying from one
259 directory into another.
260
261 (TODO: fingure out a way to see if I actually need to copy a file or
262 write it to disk, the XY-Pic package can do something similar.)
263
264
265 \end{document}
266
267
268
269
270
271 %%% Local Variables:
272 %%% mode: latex
273 %%% TeX-master: t
274 %%% End: