Page LayoutShow/hide all but section / subsection / etc. in body

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
mickey
Posts: 3
Joined: Thu Feb 11, 2010 8:22 pm

Show/hide all but section / subsection / etc. in body

Post by mickey »

I hv a .ltx file with some section/sub/subsub and text.

In one part of the document I include it per usual.

I'd like to include it as an appendix but show none of the body text. I thought I'd solved this, but searching fails. Is there a canonical way of doing this?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Show/hide all but section / subsection / etc. in body

Post by gmedina »

Hi,

I am not sure what kind of .ltx format are you talking about. In a standard LaTeX document you can use some of the features provided by the comment package. A little example:

Code: Select all

\documentclass{article}
\usepackage{comment}
\usepackage{lipsum} % just to generate some text

\begin{document}

\section{Test section}
\begin{comment}
\lipsum[1-10]
\end{comment}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
mickey
Posts: 3
Joined: Thu Feb 11, 2010 8:22 pm

Show/hide all but section / subsection / etc. in body

Post by mickey »

Sorry for being unclear. What I have is a file, say supplies.ltx, which contains something like:

Code: Select all

\section{Supplies}
\subsection{Food}
Some words about food.
\subsection{Drink}
Some words about drink.
In the main corpus I include this file, with the expected result.

I'd like to include it as an appendix later on but show only the section/subsections, without the intervening text, to make a shopping list of sorts.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Show/hide all but section / subsection / etc. in body

Post by gmedina »

Then as I said, use the comment package (link provided before). An example:

the file main.tex:

Code: Select all

\documentclass{article}
\usepackage{comment}
\usepackage{lipsum} % just to generate some text

\begin{document}

% we include all the contents of the file b.tex
\includecomment{comappend}
\include{b}
% now only the sectional unit titles of file b.tex will be included
\setcounter{section}{0}
\excludecomment{comappend}
\include{b}

\end{document}
the subsidiary file b.tex:

Code: Select all

\section{Supplies}
\begin{comappend}
  \lipsum[1-2]
\end{comappend}

\subsection{Food}
\begin{comappend}
  \lipsum[1-2]
\end{comappend}

\subsection{Drinks}
\begin{comappend}
  \lipsum[1-2]
\end{comappend}
The first inclusion of the file b.tex writes all of its contents; the second inclusion only writes the sectional unit titles (only material outside a comappend environment will be included this time).

By the way, I still don't know what you mean with .ltx format. Is it some kind of format produced by an editor?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
mickey
Posts: 3
Joined: Thu Feb 11, 2010 8:22 pm

Re: Show/hide all but section / subsection / etc. in body

Post by mickey »

Thank you; that was fabulous. I learned something new.

Now I'm trying to work out why the minimal TeX case works but migrating this into LaTeX fails; specifically the second inclusion contains all the prose, and the TOC for the second inclusion shows line numbers to the first include, and I'm pretty sure the URL package gets completely confusied (making in-document jumps wrong).

I'm also wondering why I chose LaTeX as my default, when perhaps TeX would work for this rather simple (albeit lengthy) document....
Post Reply