I have a master document for my class with a "if" statement to exclude parts (one version for my students, one for myself). My goal is to have the full Toc in the student version even if the section don't appear in the document (done in class).
Here's a way to do it in latex with this example:
Code: Select all
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\let\Contentsline\contentsline
\renewcommand\contentsline[3]{\Contentsline{#1}{#2}{}}
\newif\ifall
\allfalse
\begin{document}
\ifall
\tableofcontents
\else
\makeatletter
\input{toc_if_copy.toc}
\makeatother
\fi
\section{Section is always there}
\begin{figure}[!h]
\caption{fig A}
\end{figure}
\ifall
\section{Section is optional}
\begin{figure}[!h]
\caption{fig B}
\end{figure}
\fi
\section{Section is always there}
\begin{figure}[!h]
\caption{fig C}
\end{figure}
\end{document}
2) Compilation with \allfalse.
Is there a way to do it with Lyx? It's my favourite editor.
Thanks!