3

I have been trying to extract .tex code out of a .dtx file (this file to be precise, which should produce the microtype documentation). I understand the idea of having a single .dtx file from which all the documentation etc. can be generated but I would like to extract the .tex part and compile it independently to get a better feel of how it all works.

I have tried the suggestions in Can I convert a dtx file to tex file but I am not sure how to deal with the ifs, xdefs, mt etc.

How can I convert this .dtx to .tex?

10
  • 5
    The other question already covers the key points here: a .dtx file is a special form of .tex file and can be typeset directly. There's really no 'extract the .tex file' part to the process.
    – Joseph Wright
    Commented Aug 29, 2015 at 7:33
  • @JosephWright Thanks for your answer. What I mean by extracting the .tex part is to have a minimal working model of the .dtx file so that it produces the same documentation as output without producing other files.
    – nomad
    Commented Aug 29, 2015 at 9:10
  • 2
    Just running a .dtx file with pdflatex will often just produce the PDF: that depends on what tricks are used in the .dtx. The code is part of the typeset PDF output so you really can't start stripping out the DocStrip material.
    – Joseph Wright
    Commented Aug 29, 2015 at 9:12
  • Just running LaTeX on the file will not normally (in my experience / use case) produce the other files. (I use a separate .ins file to do that.) Commented Aug 29, 2015 at 13:26
  • @JosephWright Okay. Actually, I liked the style of the document a lot and wanted to make a template out of it for later use e.g. for writing a thesis and hence I was interested in this. Do you think there is a way to do that ?
    – nomad
    Commented Aug 29, 2015 at 23:41

1 Answer 1

4

Apart from specifics related to verbatim listing and indexing of code sections, the ltxdoc class is essentially just the standard article class.

In comments you clarified that a motivating example is the microtype documentation. the layout used there is essentially independent of the class as it redefines the entire layout in a 600 line preamble.

You can copy that preamble and use it with article class as below, I just had to comment out a few lines (marked %dpc) that were changing things specific to ltxdoc so not relevant to an article class document. The result typesets as:

enter image description here

\documentclass[10pt,a4paper]{article}
\makeatletter
%</driver>
% Let's abolish CM! We use Charter and Letter Gothic
% (for the pre-built documentation on CTAN):
 \usepackage[charter]{mathdesign}
 \def\rmdefault{bch} % not scaled
 \def\sfdefault{SourceSansPro-TLF}
 \newcommand*{\SourceSansPro@scale}{1.02}
 \def\ttdefault{blg}
 {\ttfamily\selectfont
  \DeclareFontShape{T1}{blg}{k}{n}{<-> ssub * blg/b/n}{}}
\usepackage{ifpdf,ifluatex,ifxetex}
%<*!docsty>
\usepackage[latin1]{\ifluatex lua\fi inputenc}
%</!docsty>
\usepackage[T1]{fontenc}
\usepackage{textcomp}
%dpc\GetFileInfo{\jobname.dtx}
\usepackage[expansion=false,kerning=true]{microtype}%dpc[\filedate]
 \DeclareMicrotypeSet*[protrusion]
      { doc }
      { encoding = {*, TS1, OMS},
        family   = {rm*, tt*},
        size     = {footnotesize, small, normalsize} }
 \SetProtrusion
      { encoding = OMS,
        family   = mdbch }
      { "68 = {400, },  % \langle
        "69 = { ,400} } % \rangle
 \DeclareMicrotypeSet*[kerning]
      { doc }
      { encoding = T1,
        family   = blg, % typewriter font and ...
        font     = * }  % French sample in section \ref{sub:kerning}
 \SetExtraKerning
      { encoding = T1,
        family   = blg }
      { _ = {100,100} } % underscores shouldn't touch
 \ifxetex\else
 % disable ?` and !` ligatures (sample in section \ref{sec:disable-ligatures})
 \DisableLigatures[?,!]{encoding = *, family = rm* }
 \fi
 % Fraktur sample in section \ref{sec:lettersp}
 \IfFileExists{t1mwr.fd}
   {\def\textfrak##1{{\fontfamily{mwr}\selectfont ##1}}
    \ifpdf
      \SetTracking[no ligatures={f,s,c}]{encoding=T1,family=mwr}{100}
    \fi}
   {\IfFileExists{yfonts.sty}
     {\usepackage{yfonts}
      \ifpdf
        \SetTracking[no ligatures={f,s,c}]{encoding=LY,family=yfrak}{100}
      \fi}
     {\def\textfrak{\rule{.5em}{1.5ex}\@gobble}}}
\tolerance=700
\ifpdf
  \ifnum\pdftexversion<140 \else % pdftex 1.40, including textmatrix patch,
    \microtypesetup{expansion=alltext,step=1} % hence we can activate expansion ...
    \tolerance=300         % ... and make TeX almost as intolerant as it normally is
%dpc    \g@addto@macro\macrocode{\microtypesetup{expansion=false}}
    \pdfminorversion=5 % for the OCGs
  \fi
  % bonus material
  \InputIfFileExists{microtype-logo.dtx}\relax\relax
  \InputIfFileExists{microtype-lssample.dtx}\relax\relax
  \usepackage{pdfpages}
\else
  \let\lsstyle\relax
\fi
\ifluatex % microtype.dtx finally compiles with 0.35!
  \microtypesetup{kerning=false}
\fi
\ifxetex
  \microtypesetup{kerning=false}
\fi
\usepackage{booktabs}
\usepackage{array}
 \newcolumntype{L}[1]{p{#1}<{\raggedright}}
\usepackage{color}
 \definecolor{thered}    {rgb} {0.65,0.04,0.07}
 \definecolor{thegreen}  {rgb} {0.06,0.44,0.08}
 \definecolor{theblue}   {rgb} {0.02,0.04,0.48}
 \definecolor{sectioning}{gray}{0.44}
 \definecolor{thegrey}   {gray}{0.5}
 \definecolor{theframe}  {gray}{0.75}
 \definecolor{theshade}  {gray}{0.94}
\usepackage{graphicx}
% general layout
\frenchspacing
\DeclareRobustCommand\textoractual[2]{\ifpdf
  \pdfliteral direct{/Span<</ActualText(#2)>>BDC}#1\pdfliteral direct{EMC}%
  \else #1\fi}
\expandafter\newif\csname ifcmr\endcsname
\long\def\@tempa{cmr}
\ifx\rmdefault\@tempa
  \cmrtrue
  \def\PackageFont{\sffamily}
  \def\match{\textbullet}
  \usepackage{amssymb} % \varnothing
  \let\OrigTeX\TeX
  \def\TeX{\textoractual{\OrigTeX}{TeX}}
  \setlength\textheight{49\baselineskip}
\else
  \def\bfdefault{b}
  \def\Module#1{{\color{theblue}\textoractual{$\langle$}{<}\textit{#1}\textoractual{$\rangle$}{>}}}
  \def\TeX{\textoractual{T\kern-.1667em\lower.4ex\hbox{E}\kern-.125emX\@}{TeX}}
  \DeclareRobustCommand\LaTeX{\textoractual{L\kern-.26em{\sbox\z@ T\vbox to\ht\z@{%
     \hbox{\check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont A}%
    \vss}}}{La}\kern-.1em\TeX}
  \def\PackageFont{\ttfamily}
  \def\match{{\large\raisebox{-.15em}{\textbullet}}}
  {\catcode`\`=\active % indiscernible from ' in Bitstream Letter Gothic
%dpc   \g@addto@macro\macro@code{\let`\textasciigrave}
}
  \linespread{1.07}\normalfont
  \setlength\textheight{48\baselineskip}
\fi
\addtolength\textheight{\topskip}
\setlength\topmargin{5pt}
% sections
%\def\@seccntformat#1{\setbox0\hbox to0pt{\hss\colorbox{theshade}{\space\color{sectioning}\csname the#1\endcsname\strut\space}\hskip\marginparsep}\ht0=0pt \dp0=0pt \box0}
\def\@seccntformat#1{\llap{\csname the#1\endcsname\hskip\marginparsep}}
\def\section{\@startsection {section}{1}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\normalfont\Large\fontseries{k}\sffamily\color{sectioning}}}
\def\subsection{\@startsection{subsection}{2}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\normalfont\large\fontseries{k}\sffamily\color{sectioning}}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\normalfont\normalsize\fontseries{k}\sffamily\color{sectioning}}}
\def\paragraph{\@startsection{paragraph}{4}%
  {0pt}{8pt plus 2pt minus 1pt}{-1em}%
  {\normalfont\normalsize\itshape}}
% title
\def\@maketitle{%
  \newpage\null\vskip 2em
  \begin{center}\let\footnote\thanks\sffamily
    {\huge \@title\par}\vskip 1.5em
    {\large \parbox{.33\textwidth}{\centering\@author}%
            \parbox{.33\textwidth}{\centering\@date}}%
  \vskip2.5em\rule{\textwidth}{.4pt}%
  \end{center}\par\vskip1.5em}
\def\abstractname{}
% headers
\headheight=15pt
\def\ps@MTheadings{%
  \def\@oddhead{%
    \hbox to\textwidth{\vbox{\hbox to\textwidth{%
      \footnotesize\sffamily{\leftmark\rightmark\strut}\hfill\thepage\strut}%
      \hrule height 0.4pt width\textwidth \vskip-0.4pt
    }}\hss}
  \let\@oddfoot\@empty
  \let\@mkboth\markboth
  \def\sectionmark##1{\markboth{\textls*[70]{\MakeUppercase{##1}}}{}}
  \def\subsectionmark##1{\markright{: ##1}}}
\pagestyle{MTheadings}
% toc
\let\l@section@\l@section
\def\l@section{\vskip -1.25ex\l@section@}
\def\l@subsection{\vskip.35ex \penalty\@secpenalty \@dottedtocline{2}{1.5em}{2.7em}}
\def\l@subsubsection#1#2{%
  \leftskip 4.2em
  \rightskip 2em plus 2em
  \parindent 0pt
  {\let\numberline\@gobble{\small #1~[#2]}}}
\def\l@table{\@dottedtocline{1}{0pt}{1.5em}}
\def\@pnumwidth{1.7em}
\ifpdf
  \let\ORIGpdfoutline\pdfoutline
  \def\special@outlines{attr{/F 01}}
  \def\normaloutline {\protected@write\@outlinefile{}{\let\pdfoutline \ORIGpdfoutline}}
  \def\specialoutline{\protected@write\@outlinefile{}{\def\pdfoutline{\ORIGpdfoutline\special@outlines}}}
  \g@addto@macro\appendix{\specialoutline}
\fi
\def\defspecial@toc#1#2#3{\long\def#1{%
  \ifpdf\phantomsection\specialoutline\pdfbookmark[1]{#2}{#3}\normaloutline\fi
  \section*{#2}\@mkboth{\textls*[60]{\MakeUppercase{#2}}}{}%
  \@starttoc{#3}}}
\defspecial@toc\tableofcontents\contentsname{toc}
\defspecial@toc\listoftables\listtablename{lot}
% bibliography
\def\@cite#1#2{#1\if@tempswa, #2\fi}
\def\thebibliography#1{%
  \section{\refname}%
  \list{}{\leftmargin 0pt}%
  \sloppy
  \clubpenalty 4000
  \@clubpenalty \clubpenalty
  \widowpenalty 4000}
\def\@biblabel#1{}
% footnotes
\long\def\@makefntext#1{%
  \leftskip 0pt
  \parindent 0pt
  \everypar{\parindent 0pt}%
  \leavevmode\llap{\@thefnmark\hskip\marginparsep}#1}
\renewcommand\footnoterule{%
  \kern-3\p@
  \hrule\@width \columnwidth
  \kern2.6\p@}
\skip\@mpfootins=4pt
% lists
\setlength\leftmargini{15pt}
\setlength\leftmarginii{12.5pt}
\setlength\leftmarginiii{10pt}
\def\@listi{\leftmargin \leftmargini
            \parsep 4.5pt plus 1pt minus 1pt
            \topsep 4.5pt plus 1pt minus 1pt
            \itemsep 0pt}
\let\@listI\@listi
\def\descriptionlabel#1{\hspace\labelsep\normalfont#1:}
\renewenvironment{itemize}
  {\ifnum \@itemdepth >\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter\list
      \csname\@itemitem\endcsname
      {\ifnum\@itemdepth=\@ne\leftmargin 0pt\fi
       \def\makelabel##1{\hss\llap{##1}}}%
   \fi}
  {\endlist}
\newenvironment{enum}[1][0]
  {\list\labelenumi
    {\usecounter{enumi}\setcounter{enumi}{#1}\addtocounter{enumi}{-1}%
     \renewcommand\labelenumi{\texttt{\theenumi}:}%
     \leftmargin 30pt
     \itemindent-15pt
     \labelwidth 15pt
     \labelsep 0pt
     \def\makelabel##1{##1\hss}}}
  {\endlist}
\newenvironment{options}
  {\list{}
    {\leftmargin 0pt
     \labelwidth 0pt
     \labelsep 1em
     \itemindent \labelsep
     \lstset{belowskip=0pt}}}
  {\endlist}
% boxes (for some reason, mathdesign changes these values) % still?
\setlength\fboxrule{0.4pt}
\setlength\fboxsep{3pt}
\setlength\arrayrulewidth{0.4pt}
% tables
\setlength\tabcolsep{2pt}
\long\def\@makecaption#1#2{%
  \setbox\mt@box\vbox{\llap{\vbox{% \fboxsep = 4pt
          \vskip\dimexpr\floatsep-4pt+\fboxrule\relax
          \hsize\dimexpr\marginparwidth-\marginparsep-4pt-\fboxrule\relax
          \rightskip\dimexpr\marginparsep+4pt+\fboxrule\relax plus 2.5em
          \footnotesize {\sffamily#1:}\\[-\dimexpr\aboverulesep+\cmidrulewidth+3.5\fboxrule]
          \textcolor{theframe}{\vrule width \hsize height\fboxrule}\\[.3\baselineskip]\sffamily#2}}}
  \mt@unvdimen\dimexpr\ht\mt@box+\dp\mt@box\relax
  \unvbox\mt@box
  \vskip-\mt@unvdimen}
% index and change log
%dpc\IndexPrologue{\section{Index}%
%dpc  Links (in blue) refer to the page where the corresponding entry is described
%dpc  (bold face) resp. occurs. Plain numbers (in black) refer to the code line
%dpc  where the corresponding entry is defined (underlined) resp. used.}
%dpc\GlossaryPrologue{\section{Change history}\label{sec:changes}\vspace*{-\multicolsep}}
%dpc %\setcounter{finalcolumnbadness}{100}
 %\raggedcolumns
%dpc\setcounter{IndexColumns}{2}
%dpc\def\IndexMin{12\baselineskip}
%dpc\g@addto@macro\IndexParms{%
%dpc...}
% macro code
%dpc\MacroTopsep=0pt
%dpc\MacrocodeTopsep=3pt
%dpc\setlength\MacroIndent{0pt}
\def\theCodelineNo{\reset@font\sffamily\color{thegrey}\scriptsize
  \textoractual{\arabic{CodelineNo}\ }{}}% don't copy line numbers
\def\MacroFont{\ttfamily\small}
\def\AltMacroFont{\ttfamily\footnotesize}
\def\PrintMacroName#1{\strut\MacroFont\string #1\hskip15pt}
\def\ImplementationSettings{%
  \linespread{1}%
  \hfuzz=10pt
  \def\MacroFont{\ttfamily\footnotesize}%
  \let\macro@font\MacroFont}
% additional bells ...
\def\Describe#1#2#3{\noindent\csname Describe#1\endcsname{#2}%
  \DescribeValues{#1}{#3}}
\def\DescribeOption{\leavevmode\@bsphack
  \begingroup\MakePrivateLetters\Describe@Option}
\def\Describe@Option#1{\endgroup
  \marginpar{\raggedleft\PrintDescribeOption{#1}}%
  \SpecialOptionIndex{#1}\@esphack\ignorespaces}
\def\DescribePackage{\leavevmode\@bsphack
  \begingroup\MakePrivateLetters\Describe@Package}
\def\Describe@Package#1{\endgroup
  \marginpar{\raggedleft\PrintDescribeOption{#1.sty}}%
  \CatIndex{#1}{package}\@esphack\ignorespaces}
\def\DescribeValues#1#2{%
  \let\@tempa\@empty \let\Option@default\@empty
  \@for\@tempb:=#2\do{%
    \csname Special#1Value\expandafter\endcsname\@tempb\@nil
    \expandafter\g@addto@macro\expandafter\@tempa
      \expandafter{\csname #1Sep\endcsname}%
    \expandafter\g@addto@macro\expandafter\@tempa
      \expandafter{\@tempb}}%
  \@ifnextchar[\PrintValues{\PrintValues[\Option@default]}}
\def\SpecialOptionValue#1#2\@nil{%
  \if#1:\def\@tempb{\Variable{#2}}\else %                      : = variable
  \if#1!\def\@tempb{#2}\def\Option@default{#2}\else %          ! = default
  \if#1*\def\@tempb{#2}\def\Option@default{\MaybeDefault{#2}}% * = default (maybe)
  \fi\fi\fi}
\def\SpecialMacroValue#1#2\@nil{%
  \if#1?\def\@tempb{\normalsize[\Variable{#2}]}%  % ? = optional
   \else\def\@tempb{\normalsize\{\Variable{#1#2}\}}\fi}
\let\SpecialEnvValue\SpecialMacroValue
\DeclareRobustCommand\langlechar{<} % for makeindex
\DeclareRobustCommand\ranglechar{>}
\def\Variable#1{%
  \textoractual{$\langle$}{\langlechar}%
    {\rmfamily\itshape\small#1}%
  \textoractual{$\rangle$}{\ranglechar}}
\let\m@a\meta \def\meta#1{\textoractual{\m@a{#1}}{\langlechar#1\ranglechar}}
\def\MaybeDefault#1{\textrm{*}\,#1}
\def\OptionSep{{\rmfamily, }} \def\MacroSep{\,} \def\EnvironmentSep{\,}
\def\PrintValues[#1]{{\MacroFont\expandafter\@gobble\@tempa\hfill #1}\\*[.25\baselineskip]}
\def\CatIndex#1#2{\index{#1\actualchar{\protect\ttfamily #1} (#2)\encapchar hyperpage}}
\def\SpecialOptionIndex#1{\@bsphack\CatIndex{#1}{option}%
  \index{\quotechar!Options % the `!' will be sorted first
    \actualchar{\protect\bfseries Options:}%
    \levelchar{\protect\ttfamily#1}\encapchar usage}\@esphack}
\def\SpecialUsageIndex#1{\@bsphack{\index{\quotechar!User Commands
    \actualchar{\protect\bfseries User Commands:}%
    \levelchar\expandafter\@gobble\string#1\actualchar\string\verb
      \quotechar*\verbatimchar\string#1\verbatimchar\encapchar usage}%
   \let\special@index\index\SpecialIndex@{#1}{\encapchar usage}}\@esphack}
\def\SpecialEnvIndex#1{\CatIndex{#1}{environment}}
\def\PrintDescribeMacro#1{\strut\MacroFont\color{thegreen}\string #1}
\def\PrintDescribeEnv#1{\strut\MacroFont\bslash begin\{{\color{thegreen}#1}\}%
  \\*[.25\baselineskip]\strut\bslash end\{{\color{thegreen}#1}\}}
\def\PrintDescribeOption#1{\strut\MacroFont\color{thered}#1}
\def\Indexing{\let\special@index\codeline@wrindex}
\def\NoIndexing{\let\special@index\@gobble}
\def\GeneralChanges#1{\edef\generalname{\if*#1 General\else#1\fi}}% mind the space!
\DeclareRobustCommand\key[1]{\textcolor{thered}{\ttfamily#1}}
\DeclareRobustCommand\pkg[1]{{\PackageFont#1}\@bsphack\CatIndex{#1}{package}\@esphack}
\DeclareRobustCommand\opt[1]{{\ttfamily#1}\@bsphack\CatIndex{#1}{option}\@esphack}
\DeclareRobustCommand\file[1]{{\ttfamily#1}}
\def\RequiresSep{ \textbar\ }
\def\requires#1{\let\@tempa\@empty
  \@for\@tempb:=#1\do{%
    \g@addto@macro\@tempa\RequiresSep
    \expandafter\g@addto@macro\expandafter\@tempa\expandafter{\@tempb}}%
  \hfill{\setlength\fboxsep{2pt}%
    \fcolorbox{theframe}{white}{\mdseries\small\strut\color{sectioning}%
      \,\expandafter\@gobble\@tempa\,}}}
% ... and whistles
{\catcode`\"\active
 \gdef\verbatim#1
   {\catcode`\"\active \def"##1"{\colorbox{theshade}{%
      \textrm{Text lost! Please install the \pkg{listings} package.}}}%
    \@beginparpenalty\predisplaypenalty\@verbatim\MacroFont
    \frenchspacing\@vobeyspaces\expandafter\@xverbatim\@gobble}}
\IfFileExists{listings.sty}{
 \usepackage{listings}
 \lstset{
   gobble=1,columns=flexible,keepspaces,upquote,escapechar=",
   basicstyle=\MacroFont,
   keywords=[0]{\microtypesetup,\DeclareMicrotypeSet,\UseMicrotypeSet,
     \DeclareMicrotypeSetDefault,\SetProtrusion,\SetExpansion,\SetTracking,
     \SetExtraKerning,\SetExtraSpacing,\DisableLigatures,\DeclareCharacterInheritance,
     \DeclareMicrotypeVariants,\DeclareMicrotypeAlias,\DeclareMicrotypeBabelHook,
     \LoadMicrotypeFile,\microtypecontext,\textmicrotypecontext,
     \textls,\lsstyle,\lslig,\Microtype@Hook},
   keywordstyle=[0]\color{thegreen},
   keywords=[1]{protrusion,expansion,activate,DVIoutput,draft,final,verbose,
     config,factor,auto,stretch,shrink,step,selected,unit,tracking,kerning,
     spacing,letterspace,babel,context,%defersetup,copyfonts, % undocumented
     no ligatures,outer spacing,outer kerning}, % there are three \nobreakspace in this line
   keywordstyle=[1]\color{thered},
   comment=[l]\%,
   commentstyle=\color{thegrey}\itshape,
   alsoother={0123456789_},
   frame=single,backgroundcolor=\color{theshade},rulecolor=\color{theframe},
   framerule=\fboxrule,xleftmargin=3.4pt,xrightmargin=3.4pt,belowskip=\smallskipamount
 }
 \let\verbatim\relax
 \lstnewenvironment{verbatim}[1][]{\lstset{##1}}{}
 \ifpdf \IfFileExists{dummy-space.pfb}{%
   \pdfmapline{+dummy-space <dummy-space.pfb}
   \font\dummyspace=dummy-space
   \def\lst@outputspace{% copy spaces (from a font that really has a space at x20)
     \setbox0\hbox{ }\@tempdima\wd0
     \setbox0\hbox{\dummyspace\char"20}\advance\@tempdima-\wd0
     \unhbox0 \kern\@tempdima}
  }\relax \fi
}{
 \let\lstset\@gobble
}
%\def\todo{\changes{zTo Do}{0000/00/00}}
\let\todo\@gobble
\newcommand\microtypesample[1]{\begin{quote}#1\end{quote}}
\let\emptypdfpageresources\relax
% fancy PDF document
\ifpdf
  \ifx\eTeXversion\@undefined \else % errors when not using etex (conflict with multicol)
    \ifx\pdfcolorstack\@undefined   % no longer required with pdftex 1.40
      \usepackage{pdfcolmk}
  \fi\fi
  \usepackage[bookmarks,bookmarksopen,pdfdisplaydoctitle,
              colorlinks,linkcolor=theblue,citecolor=theblue,urlcolor=thered,
              hyperindex=false,hyperfootnotes=false]
             {hyperref}
  \usepackage{hyperxmp}
  \usepackage{attachfile}
  %\usepackage{pdfpages}
  \hypersetup{
    pdftitle={The microtype package},
    pdfauthor={R Schlicht <[email protected]>},
    pdfsubject={Subliminal refinements towards typographical perfection},
    pdfkeywords={TeX, LaTeX, pdfTeX, LuaTeX, XeTeX, typography, micro-typography,
      character protrusion, margin kerning, optical alignment, font expansion,
      font scaling, hz, kerning, spacing, glue, letterspacing, tracking, ligatures}
    pdfcopyright={\textcopyright\ 2004--2013 R Schlicht\012%
      This work may be distributed and/or modified under the conditions
      of the LaTeX Project Public License, either version 1.3c of this
      license or (at your option) any later version.\&\#xA;%
      This work has the LPPL maintenance status `author-maintained'.},
    pdflicenseurl={http://www.latex-project.org/lppl/}
  }
  \pdfcatalog{/Lang(en-GB)}
  \ifnum\pdftexversion < 130 \else
    \IfFileExists{hypdestopt.sty}{\usepackage{hypdestopt}}\relax\fi
  \def\usage#1{\textbf{\hyperpage{#1}}}% for indexing of \DescribeMacro ...
  \def\changes@#1#2#3{% ... the changes ...
    \protected@edef\@tempa{\noexpand\glossary{#1\levelchar
      \ifx\saved@macroname\@empty \space\actualchar\generalname
      \else\expandafter\@gobble\saved@macroname\actualchar
        \string\verb\quotechar*\verbatimchar\saved@macroname\verbatimchar\fi
      :\levelchar #3\encapchar hyperpage}}%
    \@tempa\endgroup\@esphack}
  %\def\theCodelineNo{% % ... and everything else (would double the pdf file size)
  %  \reset@font\color{thegrey}\scriptsize
  %  \@tempcnta\arabic{CodelineNo}\advance\@tempcnta by\@ne
  %  \hypertarget{L:\number\@tempcnta}{\arabic{CodelineNo}}}
  %\def\main#1{\underline{\hyperlink{L:#1}{#1}}}
  %\def\codeline#1{\link@sanitize#1-\@nil{#1}}
  %\def\link@sanitize#1-#2\@nil{\link@@sanitize#1,\@nil}
  %\def\link@@sanitize#1,#2\@nil{\hyperlink{L:#1}}
  %\def\SpecialIndex#1{\@bsphack\special@index{\expandafter\@gobble
  %    \string#1\actualchar
  %    \string\verb\quotechar*\verbatimchar\string#1\verbatimchar
  %    \encapchar codeline}%
  %  \@esphack}
  \def\ctanurl#1{Available from \acronym{CTAN} at
                 \href{http://mirror.ctan.org/#1}{\nolinkurl{/#1}}}
  \DeclareRobustCommand\mailto[1]{\href{mailto:#1}{\nolinkurl{#1}}}
  \def\mailtoRS{\href % some PDF viewers don't like spaces:
    {mailto:<[email protected]>\%20Robert\%20Schlicht?subject=[microtype\%20\fileversion]}
    {\texttt{[email protected]}}}
  % the samples in the introduction, utilising nested optional content groups (aka. layers):
  \ifnum\pdftexversion<140 \else
    \def\mt@layer#1#2{\pdfliteral direct{/OC/#1 BDC}#2\pdfliteral direct{EMC}}
    \ifx\mt@objects\@undefined\let\mt@objects\@empty\fi
    \ifx\mt@order  \@undefined\let\mt@order  \@empty\fi
    \let\mt@resources\@empty
    \def\mt@register#1#2{%
      \immediate\pdfobj{<< /Type/OCG /Name(#1:#2) >>}
      \expandafter\xdef\csname mt@#1@#2\endcsname{\the\pdflastobj\space 0 R }
      \xdef\mt@objects  {\mt@objects        \csname mt@#1@#2\endcsname}
      \xdef\mt@order    {\mt@order          \csname mt@#1@#2\endcsname}
      \xdef\mt@resources{\mt@resources/#1#2 \csname mt@#1@#2\endcsname}}
    \xdef\mt@order{\mt@order[(Sample)}
     \mt@register{Protrusion}{true} \mt@register{Protrusion}{false}
     \mt@register{Expansion} {true} \mt@register{Expansion} {false}
     \mt@register{_compatibility}{}
    \xdef\mt@order{\mt@order]}
    \pdfcatalog{/OCProperties <<
                   /OCGs [\mt@objects]
                   /D << /Order [\mt@order]
                         /BaseState/OFF
                         /ON [\mt@Protrusion@false \mt@Expansion@false
                              \ifx\mtl@objects\@undefined\else\mtl@objects\fi] >> >> }
    \newbox\mt@box
    \newdimen\mt@unvdimen
    \def\mt@place#1{%
      \vskip-\mt@unvdimen
      \setbox\mt@box\vbox{#1}%
      \mt@unvdimen\dimexpr\ht\mt@box+\dp\mt@box\relax
      \unvbox\mt@box}
    \def\mt@pseudo@marg#1{%
      \mt@place{\llap{\vbox{%
        \hsize\marginparwidth
        \rightskip \marginparsep plus 1em
        \leavevmode\itshape\footnotesize #1}}}}
    \def\mt@show@sample#1#2{%
      \mt@layer{Protrusion#1}{%
        \mt@layer{Expansion#2}{%
          \mt@place{\microtypesetup{protrusion=#1,expansion=#2}%
            \mt@sample@text}}}}
    \def\mt@toggle@sample#1{%
      \pdfstartlink user{/Subtype/Link
        /BS << /Type/Border/W 1 /S/D /D[4 1] >>
        /H/O /C[0.65 0.04 0.07] /Contents(Click to Toggle #1!)
        %/OC << /Type/OCMD /VE[/Not \csname mt@_compatibility@\endcsname] >> % not honoured by older viewers anyway
        /A << /S/SetOCGState /State[/Toggle \csname mt@#1@true\endcsname
                                            \csname mt@#1@false\endcsname] >>}
      #1 \hfill\pdfendlink & \mt@layer{#1true}{\rlap{on}}\mt@layer{#1false}{off}}
    \renewcommand\microtypesample[1]{%
      \begingroup
      \leftskip 15pt \rightskip 15pt
      \parskip   4pt \parindent  0pt
      \vskip 8pt % = \topsep without vertical stretchability
      \long\def\mt@sample@text{#1}
      \mt@pseudo@marg{\color{theblue}%
        After you have read the text on the right, you can view the effect of
        the features it describes by clicking on the links:\strut\\
        \colorbox{theshade}{%
          \begin{tabular}{@{}>{\upshape}l@{\quad}l}
            \mt@toggle@sample{Protrusion}\\\addlinespace
            \mt@toggle@sample{Expansion}
          \end{tabular}}\\[0.3\baselineskip]
        Both features are enabled throughout this document.}
      \mt@show@sample{false}{false}
      \mt@show@sample{false}{true}
      \mt@show@sample{true} {false}
      \mt@layer{_compatibility}{%
        % for compatibility with older PDF viewers that don't support OCGs, we
        % add a layer that contains a white box, which will hide the underlying
        % layers for older viewers, and will be ignored by PDF 1.5 capable viewers.
        \mt@place{\rlap{\hskip-\marginparwidth \color{white}%
          \vrule width\dimexpr\hsize+\marginparwidth\relax height\mt@unvdimen}}
        \mt@pseudo@marg{\color{thered}%
          If you had a \acronym{PDF} viewer that understands
          \acronym{PDF}\,{\smaller1.5}, you could view the effect of the
          micro-typographic features by clicking on the links.\strut
          \\\vphantom{\colorbox{white}{\tabular l\\\addlinespace\\\endtabular}}%
          \\[0.3\baselineskip] Both features are enabled throughout this document.}}
      \mt@show@sample{true}{true}
      \vskip 4pt
      \endgroup
      \edef\x{\pdfpageresources{/Properties <<\mt@resources>>}}\x}
    \def\emptypdfpageresources{\pdfpageresources{}}
  \fi
\else
  \usepackage{url}
  \newcommand\hyperref[2][]{#2}
  \let\hyperpage\@firstofone
  \let\texorpdfstring\@firstoftwo
  \def\ctanurl{Available from \acronym{CTAN} at \url}
  \let\nolinkurl\url
  \let\mailto\texttt
  \def\mailtoRS{\mailto{[email protected]}}
\fi
\ifx\l@ukenglish\@undefined
  \hyphenation{let-ter-spac-ing let-ter-spaced let-ter-space}
\else
  \language=\l@ukenglish
\fi
\hyphenation{An-dre-as Ber-nard Ha-rald Mi-cha-el Pe-ter Ste-phan Wolf-ram
             Har-ders Hop-pe Jac-kow-ski Ku-char-czyk Mei-er Mu-the-si-us Zed-ler
             Die-te-rich
             Sveinung % ?
             Marcin % ?
             RazorXsr
             with-out
             Pa-la-ti-no}
\def\fallbacktext#1{{\centering\itshape[#1]\par}}
% abbreviations
\DeclareRobustCommand\thanh{H\`an Th\^e%
     \ifx\eTeXversion\undefined \llap{\raisebox{0.5ex}{\'{}}}
     \else \llap{\raisebox{0.45ex}{\'{}\kern\dimexpr.05em-2\fontdimen1\font\relax}}
     \fi Th\`anh}
\def\pdftex{\texorpdfstring{pdf\kern.05em\TeX}{pdfTeX}}
\def\luatex{\texorpdfstring{Lua\kern-.05em\TeX}{LuaTeX}}
\def\etex{\mbox{e-\TeX}}
\def\nonetex{\mbox{\rlap{\kern.05em/}e-\TeX}} % aka. \TeX
\def\@reflect#1{\ifdim\fontdimen1\font=0pt \reflectbox{#1}%
  \else \rotatebox[origin=c]{180}{#1}\fi}
\DeclareRobustCommand\xetex{% also reflect the initial `X'?
  \textoractual{\@reflect{X}\lower.4ex\hbox{\kern-.12em\@reflect{E}}}{Xe}%
  \kern-.16em\TeX}
\def\texlive{\TeX~Live}
\def\microtype{{\PackageFont microtype}}
\def\letterspace{\pkg{letterspace}}
\def\fontdim{\cmd\fontdimen\,}
\def\eg{e.g.}
\def\ie{i.e.}
\def\EM#1{#1\kern.1emem}
\DeclareRobustCommand\smaller{\setbox\z@\hbox{\@tempcnta=\f@size
  \edef\x{\@tempcnta=\the\@tempcnta}\expandafter}\x
  \advance\@tempcnta-7  \ifcase\@tempcnta\tiny\or\scriptsize\or
    \footnotesize\or\small\or\or\normalsize\or\or\large\or\or\or\Large\fi}
\DeclareRobustCommand\acronym[1]{\texorpdfstring{{\smaller\textls[60]{#1}}}{#1}}
\let\less=<
{\catcode`\<=\active
 \AtBeginDocument{\catcode`\<=\active
   \def<#1>{\acronym{#1}}
   \def\contributor#1 <#2\at#3>{\@contributor{#1}{#2@#3}}
   \DeclareRobustCommand\@contributor[2]{\textit{#1}}
   %\DeclareRobustCommand\@contributor[2]{\href{mailto:#2}{\textit{#1}}}
   }}
%<*driver>
%dpc\CodelineIndex
%dpc\EnableCrossrefs
%dpc\RecordChanges
%\OnlyDescription
\begin{document}

\title{Just a test}
\author{me}
\maketitle

\tableofcontents

\section{Something}
some text

\end{document}
1
  • Thank you. I had trouble realizing that the whole thing was the preamble. Thanks a lot.
    – nomad
    Commented Aug 31, 2015 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .