开发者

In LaTeX, how to generate PDF with only sections (not sub or subsubsections)

开发者 https://www.devze.com 2023-02-07 09:49 出处:网络
Is there a package or flag to pdflatex or xelatex such that if I have a document structured like \\begin{document}

Is there a package or flag to pdflatex or xelatex such that if I have a document structured like

\begin{document}

\maketitle

\section{S1}
General stuff 1

\subsection{details}
kewrweklrweewrwerwe

\section{S2}
General stuff 2

\subsection{d2}
Lorem ipsum
\sub开发者_运维知识库subsection{d3}
Even more details
\end{document}

How can I quickly generate a pdf that has just section1 general stuff 1 and section 2 general stuff 2, but no subsections?

Thanks!


Here is an extremely hackish attempt that is very fragile. Use only for testing purposes.

\documentclass{article}

\newbox\trashbox

\let\normalsection\section
\let\normalsubsection\subsection
\let\normalenddocument\enddocument
\protected\def\subsection{%
  \protected\def\section{%
    \egroup
    \let\section\normalsection
    \normalsection
  }%
  \protected\def\enddocument{%
    \egroup
    \let\enddocument\normalenddocument
    \normalenddocument
  }%
  \setbox\trashbox=\vbox\bgroup
  \normalsubsection
}

\title{abc}

\begin{document}

\maketitle

\section{S1}
General stuff 1

\subsection{details}
kewrweklrweewrwerwe

\section{S2}
General stuff 2

\subsection{d2}
Lorem ipsum
\subsubsection{d3}
Even more details
\end{document}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号