Remove space between section number and title

spacing

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?

Best Answer

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}
Related Question