summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/verbatimcopy/verbatimcopy.tex
blob: 612318ce4eeeefcc3490301ba9926e87544d7632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
\RequirePackage{etex}
\documentclass[11pt,a4paper,oldfontcommands,danish,english,article,oneside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[widespace]{fourier}
\DeclareRobustCommand{\SetFourierSpace}{%
\fontdimen2\font=1.13\fontdimen2\font}

\setlxvchars[\normalfont]

\settypeblocksize{*}{1.3\lxvchars}{1.618}

\usepackage{babel}

% for print
\setlrmargins{*}{*}{1.6}
\setulmargins{*}{*}{1.3}

% for online
\setlrmargins{*}{*}{0.7}
\setulmargins{*}{*}{1}
\setlength\marginparwidth{2.4cm}

\checkandfixthelayout

%\usepackage{felinepreamble}
%\usepackage{felinemarkup}


\usepackage[loadsampleconfig]{dlfltxbmarkup}
\usepackage{dlfltxbmisc,color}
\let\MarkWMargin=\felineWriteInMargin
\definecolor{nicered}{rgb}{.647,.129,.149}

\makeatletter
\renewcommand\feline@MWM@inner[1]{%
  \parbox[t]{\marginparwidth}{%
    \leavevmode\checkoddpage%
    \ifoddpage\RaggedLeft\else\RaggedLeft\fi%
    {\slshape\footnotesize\hspace{0pt}\color{nicered}#1\par}}}

\makeatother
\setsecheadstyle{\Large\bfseries\raggedright\color{nicered}}
\setsubsecheadstyle{\large\bfseries\raggedright\color{nicered}}


\reversemarginpar
%\twocolumnfootnotes

\setsecnumdepth{part}

\pagestyle{plain}

\begin{document}

\title{The \textsf{verbatimcopy} package\thanks{Version 0.06}}
\author{Lars Madsen\thanks{Email: daleif@imf.au.dk (packing and user docs)}
\and Ulrich Diez\thanks{Email: eu\_angelion@web.de (macro coding)}
}
\maketitle

\section{Intro}

The \textsf{\jobname} package is a package that enables \LaTeX\ to
make verbatim copies of files. Additionally one can specify which
(sub)directory to save the copy in. 

\textcolor{nicered}{\itshape\bfseries Please note that this version is
not backwards compatible! As \markup[nomk]{VerbatimCopy} now can
handle a \cs{verb}-like syntax, it can no longer be used inside other
macros. Though we do provide a compatability mode that reverts back to
the old functionality. See the \emph{Compatability} section for more
information.
}
\section{Usage}


The package provides two macros. Firstly the
\begin{syntax}
\markup{setOutputDir}\marg{dir}
\end{syntax}
macro is used for specifying which default directory to copy files to.
\markup[nomk]{setOutputDir} will automatically add a trailing
>>\texttt{/}<< if missing.
On systems that are not able to use >>\texttt{/}<< as a directory
delimiter, please redefine \markup[nomk]{VC@slash}
accordingly.\footnote{As we do not have access to systems where this
  is needed this features has not been throughly tested.}
The default output directory is the current directory. Please note
that we cannot create directories, the directory specified has to
exist beforehand.


The main macro of the package is
\begin{syntax}
  \markup{VerbatimCopy}\marg{input file}\marg{output file}
\end{syntax}
which will take a verbatim copy of \Arg{input file} and save it as
\Arg{output file}. \textit{Note:} If \Arg{output file} does not have
an extension, then \LaTeX\ gives it >>\texttt{.tex}<<.

Be very careful when using this package, it will overwrite the target
file without warning.

\section{Advanced usage}
\label{sec:advanced-usage}



Actually both \markup[nomk]{setOutputDir} and
\markup[nomk]{VerbatimCopy} supports a more \markup[nomk]{verb}-like
syntax. That is you can use a syntax similar to
\begin{syntax}
  \markup[nomk]{setOutputDir}\Arg{char}\Arg{some name not containing \textsf{char}}\Arg{char}
\end{syntax}
example
\begin{syntax}
  \verb+\setOutputDir|# #{@} b&~ $$/|+
\end{syntax}
for the already existing dir >>\verb+# #{@} b&~ $$+<<, meaning
that we can use directories with special names. Any linebreak in
the directory name or in the input or output names for
\markup[nomk]{VerbatimCopy} are silently ignored, but the spaces
do count. Many editors automatically strip spaces at
line-endings, thus avoiding linebreaks after spaces might be a
good idea.

With \markup[nomk]{VerbatimCopy} you will need two sets of \Arg{char}
characters (to replace the braces in the syntax above) and these sets
need not be the same. Example:
\begin{syntax}
  \verb|\VerbatimCopy#test.tex#+test%#2}.tex+|
\end{syntax}
meaning that the file >>\texttt{test\%\#2\}.tex}<< will be a
verbatim copy of the original file >>\texttt{test.tex}<<.

\subsection{A note about spaces in filenames}
\label{sec:note-about-spaces}

Heiko Oberdiek mentions in his  \markup[sty,nomk]{grffile} package:
\begin{quote}\itshape
  In general it is not possible to use space inside file names,
  because \TeX\ considers the space character as termination in its
  syntax for commands that expect a file name.
\end{quote}
But in most modern \LaTeX\ distributions one can use double
quotes around the filename containing spaces. If you use
\begin{syntax}
  \verb+\usepackage[enquotefilenames]{verbatimcopy}+
\end{syntax}
file-paths will get wrapped into double-quotes automatically
and you can avoid doing this ``by hand'' for the sake of avoiding
issues which might come from string-concatenation of
\markup[nomk]{setOutputDir}'s \Arg{dir} and
\markup[nomk]{VerbatimCopy}'s \Arg{output file}.

On systems that allow/require a different file-name-delimiter,
redefine \markup[nomk]{VC@quote} accordingly.

\subsection{Compatability}
\label{sec:compatability}

As mentioned ealier the macros \markup[nomk]{VerbatimCopy} and
\markup[nomk]{setOutputDir} have been changed to allow a
\cs{verb}-like functionality. This also means that
\cs{VerbatimCopy} and \cs{setOutputDir} can no longer be used
inside other macros. Some people might be able to live without
the \cs{verb}-like features and would like to be able to use
\cs{VerbatimCopy} and \cs{setOutputDir} inside other macros.
These users have two possibilities:
\begin{syntax}
  \verb+\usepackage[compatibility]{verbatimcopy}+
\end{syntax}
or
\begin{syntax}
  \cs{OldVerbatimCopy}
\end{syntax}
\begin{syntax}
  \cs{OldsetOutputDir}
\end{syntax}
(which is always available). Just note that using the `old'
macros you cannot have special characters in the filenames, but
spaces are still allowed using the syntax shown ealier (using
double quotes).

\section{A hint for programmers}
\label{sec:hint-programmers}

As mentioned earlier \markup[nomk]{VerbatimCopy} can no longer be used,
as is, inside other macros. For that you will need a trick. Here is
what Ulrich Diez provided such that this version of
\markup[sty,nomk]{verbatimcopy} works with my LaTeX-book:
\begingroup
\footnotesize
\begin{verbatim}
\makeatletter
% helper macro
\newcommand\VCverbdef[1]{%
    \VCverbaction{\expandafter\newcommand
                  \expandafter*\expandafter
                  #1\@firstofone}{}%
}%
%
% use this incase you use odd input or output filenames
\VCverbdef\felineFC@input|input with odd letter.tex|
\VCverbdef\felineFC@output+output+
% I use 'feline' for localisation in some internal macros
\newcommand\feline@run@verbatimcopy{%
  \@bsphack
  \begingroup
  \edef\@tempa{%
    \endgroup
    \noexpand\scantokens{%
      \begingroup
      \noexpand\csname VerbatimCopy\endcsname
      "\felineFC@input""\felineFC@output"%
      %\scantokens will produce a trailing space without this:
      \endlinechar=-1
    }%
    \endgroup
    \@esphack
  }\@tempa
}
\end{verbatim}
\endgroup

\section{Acknowledgement}

The main idea behind this package was originally posted on
\texttt{comp.text.tex} by Ulrich Diez
(\url{http://groups.google.com/group/comp.text.tex/msg/153e3dc7a8d0e548?hl=en}).
The idea is to use a simple, local, redefinition of
\markup[nomk]{verbatiminput}, which, instead of writing the contents
in the document, just writes it to another file.

Later Ulrich Diez provided new code that extends the original to
macros. This is the code that are currently in the \texttt{\jobname}
package, completely replacing the old code.

The \textsf{\jobname} package automatically loads the
\markup[nomk,sty]{verbatim} package.


\section{Why?}
\label{sec:why}

One might ask why the need for a functionality like this?

Here is where I use it: In my Danish 400+ pages \LaTeX\ book
(\url{http://www.imf.au.dk/system/latex/bog}), I have lots of
examples. For many of these examples I'd like to offer the source for
download (as was done for the \LaTeX\ Companion, 2nd edition). Several
examples are created using autogenerated fully compilable files that
are converted into EPS/PDF and included as graphics.  All of my
examples are of course numbered, but the actual files that make up the
external files are all individually named. To make it easier for users
to find the right code, the downloadable source files are named to fit
the example numbers in the book. So instead of writing a script to
rename files, we simply let \LaTeX\ do the verbatim copying from one
directory into another.

(TODO: fingure out a way to see if I actually need to copy a file or
write it to disk, the XY-Pic package can do something similar.)


\end{document}





%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: