Reputation: 17
I'm using a .tex
file as a subsection in my main .tex
file. In the main.tex
file I have:
\documentclass{article}
\usepackage{subfiles}
\begin{document}
\subsection{Section title}
\subfile{sub.tex}
\subsection{Section 3 title}
\end{document}
The sub.tex
file is similar to:
\documentclass[main.tex]{subfiles}
\begin{document}
\subsection{Section 2 title}
.
.
.
\end{document}
I want to keep the section numbering when I create a PDF of the main.tex
file, but I'd like to NOT have the subsection numbering when I generate a standalone PDF from the sub.tex
file.
I searched around and found somethings that kind of did what I wanted, but I was hoping, in keeping with the subfiles
package, there was an elegant way to do this?
Upvotes: 1
Views: 122
Reputation: 38967
You could change the senumdepth
in the preamble of the subfile. This won't influence the main file.
\documentclass[main]{subfiles}
\setcounter{secnumdepth}{0}
\begin{document}
\subsection{Section 2 title}
.
.
.
\end{document}
If you'd like to change this for all subfiles:
\documentclass{article}
\usepackage{subfiles}
\ifSubfilesClassLoaded{\setcounter{secnumdepth}{0}}{}
\begin{document}
\subsection{Section title}
\subfile{sub}
\subsection{Section 3 title}
\end{document}
Upvotes: 0