Text FormattingReferences to unnumbered Sections

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

References to unnumbered Sections

Post by marie2011 »

Dear forum members,

I am not sure if I should have posted this message here.

I used the symbol * in some sections because I do not want them to appear in my index. The problem now is that when I use the \ref command I get nothing but a tiny square. I was wondering if you could help me solving this problem.

My code is:

Code: Select all

\documentclass[12pt%
%,draft%
,twoside%
,BCOR10mm%
,bibtotocnumbered,
,toc=listof,
numbers=noenddot
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,ngerman,catalan,english]{babel}
\usepackage{color}
%\usepackage[round]{natbib}
\usepackage{natbib}
\usepackage{etex}
\usepackage{booktabs}
\usepackage{url}
\usepackage{paralist}
\usepackage{mystyle}
\usepackage{acronym}
\usepackage{graphicx}
\usepackage{appendix}
\usepackage{longtable}
\usepackage{color}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{tabu}
\usepackage{lscape}
\usepackage{textcomp}
\usepackage{pdflscape}
\usepackage{geometry}
\usepackage{soul}
%\usepackage{legend}

\usepackage{tablefootnote}
\usepackage{afterpage}
\usepackage{ltxtable}
\captionsetup[table]{labelsep=quad} 
\captionsetup[figure]{labelsep=quad}




%\toc=listof


\addto\captionsspanish{%
%\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listtablename}{Índice de Tablas}
\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\bibname}{Referencias bibliográficas}
\renewcommand{\appendixname}{Apéndices}
\renewcommand{\appendixtocname}{Apéndices}
\renewcommand{\appendixpagename}{Apéndices}}

%\listofgraficos
%\DeclareCaptionType{grafico}[Gr\'afico][\'Indice de Gr\'aficos]

\raggedbottom

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}


\begin{document}
%\newcommand*\nume{n"o}
\newcommand*\numer{N"o}
\newcommand*\nume{N"o}
%\include{nuevo-2}



\selectlanguage{spanish}
%\maketitle
%\includepdf{titel.pdf} 




%%% Verzeichnisse 


%\include{nuevo-2}
\pagenumbering{roman}
 \ifpdf
   \tableofcontents
 \fi

%\listofcontents
%\listoftables
%listoffigures
%\listofgraficos
%\includeonly{tableofcontents}




{\listoftables
\let\cleardoublepage\relax
\let\clearpage\relax
\listoffigures
\let\cleardoublepage\relax
\let\clearpage\relax
\listofgraficos
}


% \include{abreviaturas}
% \include{agradecimientos}
% \include{resumen}
% \include{abstract}



%%% Hauptteil
\pagenumbering{arabic}
\chapter*{Introducción}
\label{cha:introduccion-1}
\addcontentsline{toc}{chapter}{Introducción}

Se verán en~\ref{sec:objetivo-1}

Se considerarán en~\ref{sec:objetivo-1}.


\section*{Objetivo}
\label{sec:objetivo-1}

\end{document}
%%% emacs stuff %%%
%%% Local Variables:
%%% TeX-PDF-mode: t
%%% mode: auto-fill
%%% ispell-local-dictionary: "castellano8"
%%% eval: (set-input-method "spanish-prefix")
%%% TeX-master: t
%%% End:
Attached you will find a picture so that you can see what I mean.

Many thanks in advance.

Best regards,

Marie
Attachments
ref.png
ref.png (13.21 KiB) Viewed 11320 times
Last edited by cgnieder on Thu Nov 08, 2012 8:01 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

References to unnumbered Sections

Post by cgnieder »

This is standard LaTeX behaviour. \label stores the number of certain counters and \ref provides the value of the thus stored counter according to the definition \the<counter>. In case of sections it's the value of the counter section. Here is an example:

Code: Select all

\documentclass{article}
\renewcommand*\thesection{Section~\Alph{section}}
\begin{document}

\section{Title}\label{sec:title}
See: \ref{sec:title}

\end{document}
But since starred sections have no numbers there is no number to be stored and in consequence nothing to refer to. What would you like to be typeset by \ref if there is no number to be used?

Regards
site moderator & package author
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

References to unnumbered Sections

Post by marie2011 »

Hi Clemens,

Many thanks for your prompt answer.

Is it possible that if I use \ref the name of the section (in this case "objetivo") appears instead of the number section, since, as you said:

What would you like to be typeset by \ref if there is no number to be used?


Thanks and best regards,
Marie
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

References to unnumbered Sections

Post by cgnieder »

You could use the nameref package:

Code: Select all

\documentclass{scrartcl}
\usepackage{nameref}
\usepackage{hyperref}
\begin{document}

\section*{Title}\label{sec:title}
See: \nameref{sec:title}

\end{document}
Regards
site moderator & package author
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

Re: References to unnumbered Sections

Post by marie2011 »

Thanks a lot, Clemens, everything works fine now.

Best regards,

Marie
Post Reply