4

I've defined a custom section title as follows:

\renewcommand\thesection{Lecture \arabic{section} --}

This leaves an unwanted gap between "Lecture n -" and the title of the lecture. For example, \section{Linear combinations and subspaces} gives the following output:
Image of problem
I would like there to be a normal text space between the numbering and title. How can I achieve this?

Henry
  • 143

1 Answers1

4

It's better to redefine the way a section counter is formatted (via \@seccntformat) for this purpose than redefining the entire counter representation. Why? Redefining the counter representation would filter down to \labels as well, and therefore \references also.

enter image description here

\documentclass{article}

\makeatletter \renewcommand{@seccntformat}[1]{Lecture~\csname the#1\endcsname{} -- } \makeatother

\newcommand{\lecture}{\section}% For consistency sake...

\begin{document}

See Lecture~\ref{lec:linear-combinations-and-subspaces}.

\lecture{Linear combinations and subspaces} \label{lec:linear-combinations-and-subspaces}

\end{document}

Werner
  • 603,163
  • That's a brilliant solution, I wasn't aware I could do it like that. Thank you so much! – Henry Mar 01 '22 at 01:22