# How I show the counter with the part number?

Here is a MWE:

\documentclass{scrartcl}

\newcounter{main}[part]
\newenvironment{Remark}[1][]{\refstepcounter{main}\par\medskip
\noindent {\underline{\textit\Large{MAIN~:\arabic{part}.\themain}}\\ #1}}{\medskip}

\begin{document}

\part{A}

\begin{Remark}
\label{main:r1}aaa
\end{Remark}

\begin{Remark}
bbb
\end{Remark}

\ref{main:r1}
\end{document}


The output is this:

Now, I want the instead of the 1 at the bottom it will be 1.1 (the main counter and the part).

It should be as a command because I'm using LyX.
It is possible?

Thank you!!

P.S. I know I can do it with other counter (i.e. add new counter). But I wonder if I can do it with only one counter...

You have just to redefine \themain to be \arabic{part}.\arabic{main}. Then in your environment use just \themain and no more \arabic{part}.\arabic{main}. This way \ref command will use \themain as redefined and everything will be as you want to. If you want to print just the value of main counter use \arabic{main} or \the\value{main}

\documentclass{scrartcl}

\newcounter{main}[part]
\renewcommand{\themain}{\arabic{part}.\arabic{main}}
\newenvironment{Remark}[1][]{\refstepcounter{main}\par\medskip
\noindent {\underline{\textit\Large{MAIN~:\themain}}\\ #1}}{\medskip}

\begin{document}

\part{A}

\begin{Remark}
\label{main:r1}aaa
\end{Remark}

\begin{Remark}
bbb
\end{Remark}

\ref{main:r1}

\end{document}

• Where I need to put it exactly? Because when I put where you say it doesn't change anything... Only if I put it at the end of the preamble it's works. Do you know why? – heblyx Aug 12 at 14:49
• You possibly redefine something in your preamble ... or you defined the counter main after \themain and this changed back to default ... Check your whole preamble please. – koleygr Aug 12 at 15:24