0

I've been using Latex for some time now but I'm nothing but a beginner.

I would like to change the style of the heading created for my own list called "ListofZ" below. In particular I would like it to be smaller but other ways of formatting might look even better. The post How to change the style of "Contents" heading? didnt help me of course.

Now to my second problem, the list itself.

In Formatting new list of definitions with tocloft I've stumbled upon a way of defining my own list, however the code somehow doesn't work for me. When I use the code below without the "%" I always get the error

! Undefined control sequence. ...}{\protect \numberline {\thechapter .\theZ }Your text}{\thepag... l.477 \Z{Your text} The control sequence at the end of the top line of your error message was never \def'ed.

However when I comment out the two lines like below it at least prints the heading. Doesnt create a list though. I've actually just copy pasted the code so I'm not quite sure what causes the problem.

\documentclass[9pt]{article}
\usepackage{tocloft} 

\newcommand{\listZname}{ListofZ}
\newlistof{Z}{Zapala}{\listZname}
\newcommand{\Z}[1]{%
    \refstepcounter{Z}
    \par\noindent\textbf{Zapala \theZ. #1}
%   \addcontentsline{Zapala}{Z}
%   {\protect\numberline{\thechapter.\theZ}#1}
\par}

\begin{document}

\listofZ

\Z{Your text}
\Z{Your text2}

\end{document}

I've gone through the package description but unless I've missed something I haven't found an answer to my questions. Its been the first time I've explicitly looked through a description though.

If there is anything wrong with my question don't hesitate to help me correct it, this is my first post here.

I also use the packages geometry, babel, biblatex, hyperref, mathtools, amsfonts, amssymb, amsthm, enumitem, multirow if thats of any interest.

4
  • What is your actual documentclass, is it article? That class does not have a chapter level, so \thechapter is undefined. If I change your example to \documentclass{report} and run it two times then the list appears.
    – Marijn
    Dec 23, 2020 at 21:28
  • Of course if you want to use a class without chapters then you can replace \thechapter with \thesection.
    – Marijn
    Dec 23, 2020 at 21:33
  • @Marijn thanks that cleared up my second problem! (how should I make this clear in the question that I asked? Just deleting that part doesnt seem right)
    – Tork
    Dec 23, 2020 at 22:08
  • The quickest workaround for the list title size would be something like \newcommand{\listZname}{\large ListofZ} (change \large into the size that you like). There are probably better ways to do this though, this would likely give problems if you add the list in your table of contents for example.
    – Marijn
    Dec 23, 2020 at 22:30

1 Answer 1

2

Hopefully this shows the way to solve your problem. I have somewhat modified and extended your MWE (for which thanks).

% toctitleprob.tex  SE 576189

\documentclass%[9pt] % not a valid option
  {article}
\usepackage{tocloft} 

\newcommand{\listZname}{ListofZ}
%\newlistof{Z}{Zapala}{\listZname}
\newlistof{Z}{zap}{\listZname}
\renewcommand{\cftzaptitlefont}{\large\itshape}
\newcommand{\Z}[1]{%
    \refstepcounter{Z}
    \par\noindent\textbf{Zapala \theZ. #1}
   \addcontentsline{zap}{Z}
   {\protect\numberline{\thesection.\theZ}#1}
\par}

\begin{document}

\tableofcontents

\listofZ

\section{First}
\Z{Your text}
\Z{Your text2}

\section{Second}
\Z{Your text}
\Z{Your text2}

\end{document}

enter image description here

1
  • Perfect, thanks! And thanks for the extra tip as well with the font size
    – Tork
    Dec 25, 2020 at 18:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .