Graphics, Figures & TablesHide the caption in a custom tocloft "List of" system

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
petersfreeman
Posts: 19
Joined: Wed Apr 28, 2021 9:40 am

Hide the caption in a custom tocloft "List of" system

Post by petersfreeman »

I'm using tocloft to create a special list to list a half dozen poems in a large document separately from the Table of Contents as I don't want them to appear in that list or other lists.

I'm using the verse package, and it prints the poem title nicely. I want to hide the output from \mypoem{...} but still have it listed in my tocloft list.

I do want to see:

Poems

0.1 My first poem. . . . . . . . . . . 1
0.2 My second poem . . . . . . . . . 2

but I don't want to see

Poem 1. My first poem

or

Poem 2. My second poem

Code: Select all

Code, edit and compile here:
\documentclass{report}
\usepackage{tocloft}
\usepackage{verse}
\newcommand{\poemlistname}{Poems}
\newlistof{mypoem}{poe}{\poemlistname}
\newcommand{\mypoem}[1]{%
\refstepcounter{mypoem}
\par\textit{Poem \themypoem. #1}
\addcontentsline{poe}{mypoem}
{\protect\numberline{\thechapter.\themypoem}#1}\par}
\begin{document}
\listofmypoem
\section*{Document Body}
\mypoem{My first poem}
\poemtitle{My first poem}
\begin{verse}
Line 1\\
Line 2\\
Line 3\\
Line 4
\end{verse}
\mypoem{My second poem}
\poemtitle{My second poem}
\begin{verse}
Line 1\\
Line 2\\
Line 3\\
Line 4
\end{verse}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Stefan Kottwitz
Site Admin
Posts: 10312
Joined: Mon Mar 10, 2008 9:44 pm

Hide the caption in a custom tocloft "List of" system

Post by Stefan Kottwitz »

Just remove the line \par\textit{Poem \themypoem. #1} or comment it out.

Stefan
LaTeX.org admin
petersfreeman
Posts: 19
Joined: Wed Apr 28, 2021 9:40 am

Hide the caption in a custom tocloft "List of" system

Post by petersfreeman »

Thanks you, Stefan! Not understanding the code meant I was not experimenting for fear of breaking it. Wonderful!
Post Reply