Take the 2-minute tour ×
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.

To access a section (or subsection), should I always put a \label after that section or is there any way to access that specific section without using \ref in another place?

share|improve this question
2  
This question is not very clear. Can you give an example of what you'd like to be able to write, showing why the usual \label and \ref don't work in your case. –  Lev Bishop Feb 13 '11 at 18:52
    
Good question. I think it would be clearer if behind were changed to after. –  Matthew Leingang Feb 14 '11 at 15:35
    
I'm sorry... But putting \label is just too much for me, since I have to put that everywhere... Well, if there's a simpler way, I would do the simpler one, wouldn't you? :) –  zfm Feb 14 '11 at 21:06
    
@zfm: Can you please explain how you want to "access that specific section"? Do you already have an idea how that could look like? (Another thing: There's no need telling such minor edits explicitly.) –  Hendrik Vogt Feb 14 '11 at 21:20
    
just as usual.. putting section{something}\label{here} then doing ref{here} somewhere else... Since I write a lot of sections (and subsection), I am too lazy to write that \label in all sections... –  zfm Feb 14 '11 at 21:58
show 5 more comments

2 Answers

You need to use a \label after, not before, the sectioning, caption or other command you want to reference. You need to use \label and \ref, or similar commands, to access sections by label (name).

The hyperref package can create bookmark entries for the PDF without \label's which also allow you to jump to chapters, sections, etc. but it will not allow you to reference this sections from other places in the text.

share|improve this answer
    
so there is a package hyperref where I can refer section without labelling everything? That's good. –  zfm Feb 13 '11 at 18:23
    
It will create a ToC like bookmark collection, but you can not place references to certain sections in the text without \label or \hypertarget etc. –  Martin Scharrer Feb 13 '11 at 18:28
    
I think this answer would be clearer if in front and behind were changed to before and after. –  Matthew Leingang Feb 14 '11 at 12:51
    
@Matthew: Normally I would have used before and after, but the OP used in front and I wanted to match that. I changed it now. Thanks. –  Martin Scharrer Feb 14 '11 at 13:19
1  
I hadn't noticed that. I'll make the same suggestion to the question (which has a comment that "This question is not very clear") –  Matthew Leingang Feb 14 '11 at 15:34
add comment

If you are seeking a method for referring to the current section number without using \label and \ref, then you could do the following

\documentclass{article}
\begin{document}
\section{First Section}
\subsection{First SubSection}
This sentence appears in Section~\thesection, specifically,
in Subsection~\thesubsection.
\end{document}
share|improve this answer
1  
this is good, though I think that referring current section or subsection is not really useful for me... –  zfm Feb 14 '11 at 21:08
add comment

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.