LaTeX forum ⇒ GeneralEntries in a custom table are also going into the Table of Contents Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
petersfreeman
Posts: 18
Joined: Wed Apr 28, 2021 9:40 am

Entries in a custom table are also going into the Table of Contents  Topic is solved

Postby petersfreeman » Mon Sep 02, 2024 9:30 pm

I'm using this code to define a list of poems:

\documentclass[11pt,raggedbottom]{book}

\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{verse}

% For the package verse
\newcommand{\attribution}[1]{%
	\nopagebreak{\raggedleft\footnotesize #1\par}}

\renewcommand{\listfigurename}{Photos}

% Define a new custom list called "mypoem"
\newlistof{mypoem}{poe}{List of Poems}

% Command to add poems to the "List of Poems"
\newcommand{\mypoem}[1]{%
	\refstepcounter{mypoem}%
	\addcontentsline{poe}{mypoem}{#1}%
	#1\par}

\begin{document}
	
	\tableofcontents
	
	% Generate the "List of Poems"
	\listofmypoem
	
	\chapter{Introduction}
	
	\lipsum[1]
	
	\mypoem{To the Lighthouse -- Virginia Woolf}
	
	\vspace{5ex}\poemtitle{To the Lighthouse}
	
	\begin{verse}[4em]
		And all the lives we ever lived\\
		And all the lives to be,\\
		Are full of trees and changing leaves\ldots{}\\!
		\attribution{Virginia Woolf}
	\end{verse}

	\lipsum[2]
\end{document}


It does this successfully, but it also adds an entry into the "Table of Contents" which I don't want. How do I stop it from placing an entry into the "Table of Contents"?

"To the Lighthouse – Virginia Woolf" also appears above the poem which I don't want.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
petersfreeman
Posts: 18
Joined: Wed Apr 28, 2021 9:40 am

Entries in a custom table are also going into the Table of Contents

Postby petersfreeman » Mon Sep 02, 2024 11:23 pm

I found the solution. I needed to change \poemtitle{To the Lighthouse} to a starred version: \poemtitle*{To the Lighthouse} to stop it putting entries into the table of contents.


Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests