# How to generate a Makefile from dtx // keeping the tab width

For a complete documentation I would like to maintain and explain the Makefile within my dtx-file.

Two problems occur:

1. docstrip always adds an extension to the generated file (\file{Makefile}{\from{\jobname.dtx}{make}})

2. The tab in the Makefile is not preserved and got erased (all: [[TAB]]lualatex $(NAME).tex) This is my MWE: %\iffalse %<*internal> \iffalse %</internal> %<*internal> \fi \def\nameofplainTeX{plain} \ifx\fmtname\nameofplainTeX\else \expandafter\begingroup \fi %</internal> %<*install> \input docstrip.tex \keepsilent \askforoverwritefalse \nopreamble\nopostamble \generate{ \file{Makefile}{\from{\jobname.dtx}{make}} } %</install> %<install>\endbatchfile %<*internal> \usedir{source/latex/\jobname} \generate{ \file{\jobname.ins}{\from{\jobname.dtx}{install}} } \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else \expandafter\endgroup \fi %</internal> %<*driver> \documentclass{ltxdoc} \begin{document} \DocInput{\jobname.dtx} \end{document} %</driver> %\fi %\iffalse %<*make> %\fi % \section{The Makefile} % \begin{macrocode} NAME = testfile % \end{macrocode} % The default command % \begin{macrocode} all: lualatex$(NAME).tex
%    \end{macrocode}
%\iffalse
%</make>
%\fi
\endinput


# EDIT

After the first run in the terminal with lualatex DOCUMENT.dtx I get the makefile. Then I cannot simply run make but have to type in make --makefile=Makefile.tex and get the error *** missing separator. Stop.

• I tend to write raw Makefiles for LaTeX documents – Robin Oct 1 '18 at 13:59
• Sure, me too. But then I have to write all the comments in the makefile. As I wrote, this is purely for documenting reasons. – LukasCB Oct 1 '18 at 14:00

In the dtx code as posted there are no tabs (as the site changes them to spaces) but if I put tabs back in the Makefile section and modify the .ins to look like

\catcode9=12
\generate{
\file{Makefile}{\from{\jobname.dtx}{make}}


Then tabs are written to the Makefile if I use luatex on the .ins. (The resulting file gets called Makefile.tex though. (Extensionless files are tricky in TeX)

So if you replace the spaces before lualatex $(NAME).tex by a tab in the file below then luatex file.dtx  will generate file.ins and luatex file.ins  will generate a Makefile.tex with tabs (at least on cygwin texlive 2018 luatex) %\iffalse %<*internal> \iffalse %</internal> %<*internal> \fi \def\nameofplainTeX{plain} \ifx\fmtname\nameofplainTeX\else \expandafter\begingroup \fi %</internal> %<*install> \input docstrip.tex \keepsilent \askforoverwritefalse \nopreamble\nopostamble \catcode9=12 \generate{ \file{Makefile}{\from{\jobname.dtx}{make}} } %</install> %<install>\endbatchfile %<*internal> \usedir{source/latex/\jobname} \generate{ \file{\jobname.ins}{\from{\jobname.dtx}{install}} } \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else \expandafter\endgroup \fi %</internal> %<*driver> \documentclass{ltxdoc} \begin{document} \DocInput{\jobname.dtx} \end{document} %</driver> %\fi %\iffalse %<*make> %\fi % \section{The Makefile} % \begin{macrocode} NAME = testfile % \end{macrocode} % The default command % \begin{macrocode} all: lualatex$(NAME).tex
%    \end{macrocode}
%\iffalse
%</make>
%\fi
\endinput

• ok, I could live with naming it to Makefile.make but where exactly should I put \catcode9=12. When I put it where you are pointing it to I get ! LaTeX Error: Missing \begin{document}.. – LukasCB Oct 1 '18 at 14:07
• @LukasCB I added full example – David Carlisle Oct 1 '18 at 14:17