I have a really strange problem. In one of my papers, the references to sections are simply not printed. I compile with pdflatex, it works without complaints, and it spits out the pdf, but without any of the references to sections.
I am just using \label{sec:mysec} after a section and \ref{sec:mysec} anywhere in the text, which is the typical use. I have used this for years but in this particular document there must be an interaction with something that prevents latex from showing the references.
In case it helps, these are the packages I am importing:
\documentclass[a4paper,man,natbib,floatsintext]{apa6}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{color}
\usepackage{array}
I have no clue where it could be coming from. Any hints would be very welcome.
Thanks a lot!
From the apa6 documentation (section 3.4 Heading levels, p 5):
Please note that sections cannot be
\ref'd since APA style does not use numbered sections. So\labelcommands are unnecessary unless you wish to use\refname.
\refname only gives you access to the References section title, if you use it. All sections within an apa6 document are printed without numbers (stemming from \setcounter{secnumdepth}{0} within the class), so \label and \ref doesn't make much sense:

\documentclass{apa6}
\begin{document}
\section{A section}
\label{sec:section}
\section*{Another section}
See section~\ref{sec:section}.
\end{document}
You can manually set what \label should store and reference it later using the following \setlabel{<stuff>}{<label>} option:

\documentclass{apa6}
\makeatletter
\newcommand{\setlabel}[1]{\edef\@currentlabel{#1}\label}
\makeatother
\begin{document}
\section{A section}
\setlabel{A section}{sec:section}
\section*{Another section}
See section~\ref{sec:section}.
\end{document}
If you wish to automate this process, you can patch \@sect and \@ssect within the LaTeX kernel in the following way:

\documentclass{apa6}
\usepackage{etoolbox}
\makeatletter
% \pretocmd{<cmd>}{<prefix>}{<success>}{<failure>}
\pretocmd{\@sect}{\def\@currentlabel{#8}}{}{}% Store title of \section
\pretocmd{\@ssect}{\def\@currentlabel{#5}}{}{}% Store title of \section*
\makeatother
\begin{document}
\section{A section}
\label{sec:section}
\section*{Another section}
See section~\ref{sec:section}.
\end{document}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With