7

I want to counter paragraphs, always like x.y where x is section number and y is paragraph number in that section.

\documentclass[11pt, twocolumn, a4paper]{article}
\usepackage[left=1.5cm, text={18cm, 25cm}, top=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[IL2]{fontenc}
\usepackage[czech]{babel}
\usepackage{times}

\begin{document}
\section{A}
foo
\paragraph{Definition % 1.1 %}
here is definition 1.1 and i need to reference it later as 1.1
\section{B}
 bar
 \paragraph{Definition % 2.1 %}
\end{document}

Can anyone help please?

  • Do you have \subsections? What about \subsubsections? What \documentclass are you using? Please provide the community with a minimal working example (MWE). – Werner Mar 26 '14 at 23:47
  • 1
    \paragraph is defined to be the section level below \subsubsection It is possible to redefine things to lose subsection and subsection but it's a lot simpler to simply use them. – David Carlisle Mar 26 '14 at 23:52
  • 3
    Consider using amsthm, and welcome to TeX.SX :) – Sean Allred Mar 27 '14 at 0:06
  • @SeanAllred: ty! That was exactly what i needed. – Krab Mar 27 '14 at 0:31
3

Here are some options:

  1. You can make \paragraph act in exactly the same way as \subsection by adding

    \let\paragraph\subsection
    

    to your document preamble. Or, simply use \subsection directly.

    enter image description here

    \documentclass{article}
    \let\paragraph\subsection% Make \paragraph act just like \subsection
    \begin{document}
    \section{A}
    foo
    \paragraph{Definition}
    Here is definition 1.1 and i need to reference it later as 1.1
    
    \section{B}
    bar
    \subsection{Definition}
    
    \end{document}
    
  2. Adjust the way \paragraphs are number by adding

    \renewcommand{\theparagraph}{\thesection.\arabic{paragraph}}% How paragraphs are numbered
    \setcounter{secnumdepth}{4}% Number up to paragraphs
    

    to your document preamble. The first command adjusts paragraphs to by numbered "like section"."paragraph". The second actually allows paragraphs to be numbered using the traditional sectional unit numbering condition.

    enter image description here

    \documentclass{article}
    \renewcommand{\theparagraph}{\thesection.\arabic{paragraph}}% How paragraphs are numbered
    \setcounter{secnumdepth}{4}% Number up to paragraphs
    \begin{document}
    \section{A}
    foo
    \paragraph{Definition}
    Here is definition 1.1 and i need to reference it later as 1.1
    
    \section{B}
    bar
    \subsection{C}
    foo bar
    \paragraph{Definition}
    foo bar foo
    
    \section{D}
    foo bar foo bar
    \subsection{E}
    bar foo bar foo
    \subsubsection{F}
    foo bar foo bar foo
    \paragraph{Definition}
    
    \end{document}
    

    The problem here is that you may confuse your readers if you mix \subsections and \paragraphs, since they are numbered similarly. Moreover, their numbering doesn't adjust with each section (for example, restarting). If you want them to restart, then consult Continuous v. per-chapter/section numbering of figures, tables, and other document elements. The suggestion there is to use

    \usepackage{chngcntr}% http://ctan.org/pkg/chngcntr
    \counterwithout{paragraph}{section}
    

    Do this before redefining \theparagraph.

  • this is not why i need, because if paragraph is in subsection, the counting is wrong. If the paragraph is anywhere, it must always have number section.paragraphNumberInThatSection – Krab Mar 27 '14 at 0:08
  • @Krab: I've added something to that effect. However, I also mention why it seems problematic. – Werner Mar 27 '14 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.