3

Today I got the idea that I need a list of "things" in my document. I don't have any figures so I planned to use the list of figures feature. Here is the MWE:

\documentclass[letterpaper,11pt,pagesize=pdftex,openright,headings=twolinechapter,chapterprefix=true]{scrbook}

\renewcommand\listfigurename{List of API Addresses}

\begin{document}

\frontmatter

\mainmatter

\addcontentsline{lof}{lof}{/api/SystemProperties}
\addcontentsline{lof}{lof}{/api/Foo}
\addcontentsline{lof}{lof}{/api/XXX}

\backmatter


\listoffigures

\end{document}

When I process the document, I get a list of figures that looks like this:

document produced

No line returns. I can't figure out what I am doing wrong. All the examples I have seen from various sources have a nice numbered list with the page numbers tabbed to the right ... which is pretty much exactly what I would like.

I have another problem that in my real document something is putting addvspace, but because there is not end of the paragraph, LaTeX complains about the addvspace when not between paragraphs. I think if I can fix the above, then this problem with addvspace will go away.

4
  • 2
    The second argument of the \addcontentsline macro should be figure. Try \addcontentsline{lof}{figure}{/api/FOO}.
    – GuM
    Nov 15 '17 at 20:14
  • You probably want to use \addcontents, unless you want the page number at the end of each line. Nov 15 '17 at 20:18
  • @GuM changing to figure worked. Kormylo the addcontents give me "not defined".
    – AgilePro
    Nov 15 '17 at 20:27
  • Oops, \addtocontents. Nov 15 '17 at 21:54
2

The second argument of the \addcontentsline macro should be figure. For example, this code

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\renewcommand*{\listfigurename}{List of API Addresses}



\begin{document}

\addcontentsline{lof}{figure}{/api/SystemProperties}
\addcontentsline{lof}{figure}{/api/Foo}
\addcontentsline{lof}{figure}{/api/XXX}

\listoffigures

\end{document}

produces this output:

Output of the code

4
  • Thanks for the answer. And may I add .... the documentation and error messages are ABYSMAL.
    – AgilePro
    Nov 15 '17 at 20:28
  • @AgilePro: In what sense, “abysmal”? What documentation are you reading?
    – GuM
    Nov 15 '17 at 20:31
  • See source2e.pdf from CTAN. Nov 15 '17 at 21:55
  • @JohnKormylo: I assume you are referring to the comments that accompany the definition of the \addcontentsline macro; well, they are terse, but exact.
    – GuM
    Nov 15 '17 at 22:01
1

tocloft is a package which allows to decide list of ... aspect, but also allows an easy declaration of new table of whatever. Following its documentation I've managed to do following example:

\documentclass[letterpaper, 11pt, pagesize=pdftex, openright, headings=twolinechapter, chapterprefix=true]{scrbook}

\usepackage{tocloft}

\newcommand{\listapiadd}{List of API addresses}
\newlistof{apiadd}{api}{\listapiadd}

\newcommand{\apiadd}[1]{%
    \refstepcounter{apiadd}
    \texttt{#1}%
    \addcontentsline{api}{apiadd}{\protect\numberline{\theapiadd}\texttt{#1}}}

\begin{document}
\frontmatter
\mainmatter

This is an \apiadd{/api/SystemProperties}, and these are two more \apiadd{/api/Foo}, \apiadd{/api/XXX}.

\backmatter
\listofapiadd
\end{document}

![enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.