tags:

views:

20

answers:

1

I'm trying to change the appearance of one of the native sectioning commands in LaTeX. But after doing so, latex cannot handle references as expected.

The code given later is expected to output a document with the text

1 One
See section 2. 

2 Two
See section 1.

But instead I get the following.

1 One
See section . 

2 Two
See section .

What can I change in the renewed command, such that the references will work again.

The code for the document is as follows:

\documentclass{article}

\newcounter{seccnt}
\renewcommand{\section}[1]{\vspace{2em}\stepcounter{seccnt} \theseccnt~ {\Large #1}\vspace{0.5em}}

\begin{document}

\section{One}
\label{secOne}

See section \ref{secTwo}.

\section{Two}
\label{secTwo}

See section \ref{secOne}.

\end{document}
+1  A: 

I think you need to use \refstepcounter instead of \stepcounter, so that the reference is stored.

Svante
This was the simplest possible solution. I was not aware of the \refstepcounter command, but it is usefull.
midtiby