TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It is well-known that \section environment may be assigned a label \label{refname} and then the refname may be used in order to reference this section:

\section{My nice section}
\label{sec:my-nice-section}
Definitely the section is nice!

\section{My another section}
In the section \ref{sec:my-nice-section} we have discovered that it is nice.

Is there such possibility for \paragraph that we can assign it a label and then reference it?

share|improve this question
    
technically \section is a control sequence, not an environment ;) – Ruben Mar 21 at 3:18
up vote 24 down vote accepted

Sure - if it has a number which can be referenced:

\documentclass[10pt,twocolumn]{article}
\setcounter{secnumdepth}{6}
\begin{document}
\paragraph{blub}\label{para}
abc paragraph \ref{para}
\end{document}
share|improve this answer
3  
\setcounter{secnumdepth}{6} is the answer, thanks – Tim Dec 23 '10 at 12:00

Here another approach which I find more direct, easy, and appropriate to the question posted above (source: wikibooks):

%The link location will be placed on the line below.
\phantomsection
\label{the_label}

The good thing is that \ref{} will produce the number of the section the paragraph is entailed, \pageref{} will produce the pagenumber where the paragraph is to be found and if hyperlinks are produced automatically with e.g. the hyperref-package clicking on the link beams one to the beginning of the referenced paragraph, ... so correct, consistent, and userfriendly behaviour! :-)

share|improve this answer
1  
But it won’t work the way the OP wants, as long the \paragraph is without a number. – Speravir Oct 17 '12 at 17:53
    
Jip, but if a direct paragraph-number is needed it maybe would be wiser to go for a section / subsection / subsubsection / ... which does the numbering automatically because paragraphs are thought to be not numbered. – petermeissner Oct 18 '12 at 8:22
    
Ultimately, wouldn't you want your text to say something like ".... as described in the 2nd paragraph in section X.Y" or "...paragraph 2 in section X.Y addresses this point...". So therefore, whilst you may not display a number like in a chapter, section or subsection, maybe define a new counter, and set the \par command to increment the counter. Resetting the counter at start of new section, subsection or chapter etc... – Nicholas Hamilton May 16 '13 at 11:35
    
Again, if something is so important that it needs explicit numbering, why not go for a build in solution with section, subsection ... IMHO: Either I would write "as described in section\ref{sectionlabel}" or I would go for "As described on page~\pageref{phantomsectionlabel}" ... Either way, the solution above makes referring to paragraphs possible - that was the question. It has small overhead. It is good style. (IMHO) ... if you do not like it and you insist on counting paragraphs go for solutions which have more overhead like the one of Ulrike Fischer posted here. – petermeissner Feb 5 '14 at 11:28
2  
+1 I like not having to give the paragraph a number. I can reference the section it goes to and have it land on the exact paragraph. – spdickson Mar 7 '14 at 22:25

I agree that the \setcounter{secnumdepth}{6} is an answer (though, \setcounter{secnumdepth}{4} is enough, because 5 is a subparagraph. The side effect is, however, that paragraph appears numbered.

The numbering can be suppressed with the help of the titlesec package which allows quite full control over titles. Just use the package and add:

\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{}{0pt}{}

Here [runin] means that the title is inline with the text; {\normalfont\normalsize\bfseries} is the format of the whole title; {} is empty label - and it suppresses the visible paragraph numbering. {0pt} is distance between label (anyway, non-existent) and title, but must be valid length; {} is needed for some intricate formatting; I always leave it empty.

share|improve this answer
    
This is more a commentary on the post by @UlrikeFischer. The OP did not ask for unnumbered paragraphs in the first place. – Ruben Mar 21 at 3:17
    
Indeed; however, the OP clearly had initially unnumbered paragraphs. Suggestion of @UlrikeFischer solves the problem, but has a side effect as paragraphs numbering. So, I thought that it is useful to know how to counteract the side effect. – Viatcheslav Nesterov Mar 23 at 22:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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