0

This question already has an answer here:

In an article I omit the section number for subsection titles, using:

\renewcommand\thesubsection{\arabic{subsection}}

However, when I now create a \label in a subsection and reference it using \ref in another part of the document, the printed reference only shows the subsection number, even in a totally different section! How can I show the section AND subsection number in references (as usual) while keeping only the subsection number in subsection titles?

MCVE:

\documentclass{article}

\renewcommand\thesubsection{\arabic{subsection}}

\begin{document}

\section{My first section}

\subsection{Foo}

\subsection{Bar}
\label{ssec:bar}

\section{My second section}

\subsection{Misc}

\subsection{Notes}

See also subsection \ref{ssec:bar}.

\end{document}

The printed reference shows 2, however, I want it to be 1.2.

marked as duplicate by Community Feb 13 at 17:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • remove \renewcommand\thesubsection{\arabic{subsection}}. than will work as desired. – Zarko Feb 13 at 16:47
  • @Zarko then the subsection title will also contain the section number, which I don't want – Cybran Feb 13 at 16:50
  • than you can't expect desired numbering in references. reference always reproduce number of section. – Zarko Feb 13 at 16:52
  • 1
    Try \makeatletter\renewcommand\p@subsection{\thesection.}\makeatother. See also tex.stackexchange.com/q/186974/35864, tex.stackexchange.com/q/67742/35864 and tex.stackexchange.com/q/437402/35864 – moewe Feb 13 at 17:21
  • Thanks @moewe, that was exactly what I was looking for. I marked the question as duplicate – Cybran Feb 13 at 17:56