3

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?

1

1 Answer 1

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}
1
  • That's a brilliant solution, I wasn't aware I could do it like that. Thank you so much!
    – Henry
    Mar 1, 2022 at 1:22

You must log in to answer this question.

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