[texhax] vanishing tab characters and docstrip

Mathias Bauer listensammler at gmx.net
Mon Oct 19 17:42:57 CEST 2009

Hello list!

With docstrip and the package doc, I want to generate commented
Makefile code (and code using other programming languages, too)
instead of LaTeX code.  Running either tex or latex on the .ins
installation file
    latex test.ins
kills all tab characters at the beginning of a line.  Because of
the Makefile syntax requiring tab characters at the beginning of
some lines, docstrip's behaviour is unsolicited and in some sense

Here are the two files of a minmalistic example, the .ins
installation file `test.ins' and the .dtx documented source code
file `test.dtx':

----------snip---------- test.ins ----------snip----------
\input docstrip
% ---------- Misc ----------
% ---------- LaTeX driver ----------
% ---------- Makefile ----------
% Trick from bibexports
Preamble for the Makefile.
% Trick from apacite
  \MetaPrefix ^^J%
  \MetaPrefix\space End of `\outFileName'.}%
----------snap---------- test.ins ----------snap----------


----------snip---------- test.dtx ----------snip----------
% \iffalse
% \fi
% Documentation\ldots
% \StopEventually{}
% Implementation\ldots
%    \begin{macrocode}
# Lines starting with tab character:
	echo Hello world!
	@echo Hello world again!
	printf "Hello\tworld!\n"
# Lines starting with blanks:
%    \end{macrocode}
% \Finale
----------snap---------- test.dtx ----------snap----------

Searching for an explanation of docstrip's behavior, I looked
into docstrip.tex and its documentation.  There, the macro
\readsource (l. 584) reads the .dtx documented TeX file line
after line and calls \processLine (l. 344).  \processLine uses
\normalLine (l. 314+) - and all seems to be very unsuspicious to

  \let\do\putline at do

Then the macro \putline at do is executed

\def\putline at do#1#2#3{%

and finally the real work is be done by \StreamPut (l. 203):


I didn't find any implementation of \immediate or \write either
in docstrip.tex nor in the whole LaTeX code (source2e), so it
seems to be pure TeX (which I didn't know much about).  But where
in this whole process the tab characters vanish?

How can I avoid docstrip killing tab characters at the input
line's beginning?  Can anybody give me a hint?

Many thanks in advance,

More information about the texhax mailing list