0

I defined a new paragraph with one counter in this way: \def\newparagraph{\paragraph{\counter}} Is there a way to release this kind of label?

\label{\value{chapter}.\value{\counter}}
5
  • 1
    Please respect the Markdown Format, you may want to read also Welcome to TeX.SX!
    – Cfun
    Jul 6, 2016 at 10:52
  • 3
    The purpose of a label is its easy to remember name, not \label{2.3}. I need no label then :-(
    – user31729
    Jul 6, 2016 at 11:03
  • you may need to read these comments
    – Cfun
    Jul 6, 2016 at 11:06
  • 4
    never use a numeric label, it defeats the purpose. Jul 6, 2016 at 11:49
  • 1
    is that your actual definition? if \counter works in \value then it must be the name of a counter, so expand to something like section or footnote etc, so \newparagraph always makes a section heading with the same text, the name of a counter???? Jul 6, 2016 at 13:46

1 Answer 1

1

You surely can do

\newcounter{leo}
\newcommand{\newparagraph}{%
  \refstepcounter{leo}%
  \paragraph{\theleo}%
  \label{\thechapter.\theleo}%
}

but the label will serve no purpose whatsoever.

Suppose that, at one point when writing the document, your \newparagraph gets the number 4.1 (second numbered paragraph in chapter 4). You'll happily refer to it by \ref{4.1}. The next day, you decide that, after all, there should be another numbered paragraph before the already written one. You'll need to chase down all \ref{4.1} (and the ones of the form 4.x) in order to change them for reflecting the current situation.

The next day you (or your thesis advisor) decide that, after all, the two numbered paragraphs should be merged into one. And so on and so forth.

Do, instead,

\newcounter{leo}
\newcommand{\newparagraph}{%
  \refstepcounter{leo}%
  \paragraph{\theleo}%
}

and use

\newparagraph\label{wonderful} This is my wonderful paragraph

so you can refer to it by \ref{wonderful}.

2
  • I'm sorry.. there is a way in order to make that the counter ''leo'' restart to ''1'' in each section? @egreg
    – Andrea Leo
    Jul 8, 2016 at 10:14
  • @AndreaLeo \newcounter{leo}[section]
    – egreg
    Jul 8, 2016 at 11:00

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