[texhax] List of Examples

Uwe Lueck uwe.lueck at web.de
Fri Sep 25 00:23:02 CEST 2015


On Mittwoch, 23. September 2015 um 23:22 Uhr, Robert Scholtz a écrit:
>
> I would like to create a list of Examples following the TOC much as
> \listoffigures and \listoftables does in LaTeX book typesetting.
> 
> Using the theorem environment, I’ve inserted the following instructions:
> 
> \newtheorem{exform}{Example }[chapter]
> \newcommand{\bexample}[1]{\begin{exform}\rm : #1\hskip1em \hrulefill\vskip0pt\nobreak\noindent}

from minor to major: \hskip...\noindent strange, if you want to start 
a new line without indent and without "\underfull" messages on the 
same page indeed, that sequence may better be replaced by

    \\*

I have actually studied The TeXbook and latex.ltx again, painfully, 
\vskip includes \par in some way, it seems to be very difficult 
to avoid a page break after a header paragraph, a final \par either 
must happen inside a \box, or the \nobreak preceding \parskip 
must be issued by \vadjust still from the earlier horizontal list.

\listoffigures and \listoftables work due to LaTeX's "float" mechanics. 
Packages varying them are listed on these CTAN pages:

    http://ctan.org/topic/float

    http://ctan.org/topic/caption

You may not want to have your examples float, "nonfloat" and the 
"[H]ere" option from "float" may help for this. "float", "newfloat", 
"trivfloat" (and others?) enable you to create another type of 
"floats" besides "figure" and "table" which may get ist own "list of"
near the TOC / lists of figures/tables.

Captions are typeset /below/ figures/tables by default, but there are
ways to change this. If your examples are small (high/deep) enough, 
maybe you want to have them on a single (same) page indeed. This would 
be great for using a non-floating type of floats.

Otherwise my idea would be to implement the "example" header as a 
(fake) non-floating float, forbidding a following page break (by some 
hack). Or you only declare a third "float" type by one of the packages 
named above and then insert a corresponding \addcontentsline in the 
header macro. The latter's first argument is "toc" for the main TOC, 
otherwise an identifier for the corresponding list of "floats".

Hm, I hope ...

    Uwe.





More information about the texhax mailing list