5

It seems that changing secnumdepth does not change anything in my document for me. I want secnumdepth to be 2, so that I can label and reference subsections.

However, subsection stay unnumbered for some reason, which has the consequence that when referencing these subsections, I get the section number instead. So if I were to reference subsection 1.1.2, I'd get section 1.1 instead. This is rather annoying, and I'm not quite sure what's going on. I've even tried changing secnumdepth to values ranging from 0 to 4, but even that does not change anything in my document. I do not receive any warnings or errors about this. My guess is that somewhere, a more dominant definition was made, but since my secnumdepth is defined at the bottom, that seems a bit unlikely.

I'm using a template from my university, and I'd like to think that I understand it fully, but somewhere I apparently don't.

\documentclass[a4paper,10pt,oneside,openright]{memoir}

\usepackage{pdfpages}                           
\usepackage{fix-cm}                             
\usepackage[breaklinks,pdfpagelabels]{hyperref} 
\usepackage[official]{eurosym}                  
\usepackage{subfig}                             
\usepackage[english]{babel}                     
\usepackage{wrapfig}
\usepackage{graphicx}                           
\usepackage{amsmath}                            
\usepackage{amssymb}                           
\usepackage{units}
\usepackage{amsmath}
\usepackage[numbers,sort&compress]{natbib}      
\usepackage{todonotes}
\usepackage{ctable}                             
\usepackage{multirow}                           
\usepackage{xfrac}                              
\usepackage{easytable}
\usepackage{gensymb}

\setcounter{topnumber}{3}           
\setcounter{bottomnumber}{1}        
\setcounter{totalnumber}{4}       
\renewcommand{\topfraction}{0.8}    
\renewcommand{\bottomfraction}{0.8} 
\raggedbottom

\settypeblocksize{*}{14cm}{1.618}
\setlrmargins{3cm}{*}{*}
\setulmargins{3cm}{*}{*}
\checkandfixthelayout

\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\definecolor{darkgreen}{rgb}{0.0,0.3,0.0}
\hypersetup{        
    colorlinks,          % links are colored
    urlcolor=blue,       % color of external links
    linkcolor=darkblue,  % color of internal links
    citecolor=darkgreen, % color of links to bibliography
    bookmarksnumbered
}
\urlstyle{rm}

\newcommand{\intd}[1]{\ensuremath{\,\textrm{d}#1}}

\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{2}

I have also added my document assembly

\begin{document}
\frontmatter
\includepdf{frontpage} 
\include{abstract}
\tableofcontents

\mainmatter
\include{chapters/Introduction}
\include{chapters/Concept}
\include{chapters/Digital}
\include{chapters/Analog}
\include{chapters/Results}
\include{chapters/Discussion}
\include{chapters/Conclusion}

\backmatter
\bibliographystyle{unsrtnat}
\bibliography{icdtemplate} %requires mscthesis.bib file in your directory; use e.g. JabRef in combination with bibtex to generate it.

\appendix
\include{chapters/appendix1}
\include{chapters/appendix2}
\end{document}
4
  • 1
    Welcome to TeX.SX! I can't reproduce your issue with \begin{document} \chapter{Foo}\label{sec:foo} \section{Bar}\label{sec:foo:bar} \subsection{Baz}\label{sec:foo:bar:baz} \ref{sec:foo} \ref{sec:foo:bar} \ref{sec:foo:bar:baz} \end{document} added to your (not-so-minimal) MWE.
    – Skillmon
    Commented Oct 31, 2019 at 10:06
  • Thanks for your reply. I have added my document assembly as well. Inside the documents, I don't do anything regarding defining specific layout properties. I see you are using a structure of sec:foo:bar:baz, etc. I simply give it a unique name. Is your structure required for everything to work as expected? Commented Oct 31, 2019 at 15:29
  • No, this structure isn't required, the only thing that's important is distinct names which don't contain any evil character (meaning any character that might expand to something, e.g. ~ or other active characters).
    – Skillmon
    Commented Oct 31, 2019 at 15:30
  • And we can't do anything with your document assembly, as we don't have any of the required files on our system. Could you please edit your MWE (take a look here: minimal working example (MWE)) so that it is reproducible for us and produces your issue?
    – Skillmon
    Commented Oct 31, 2019 at 15:32

2 Answers 2

6

The preferred method with memoir is to say

\settocdepth{section}
\setsecnumdepth{subsection}

instead of setting the counters tocdepth and secnumdepth. If I do it and try with a skeleton document

\begin{document}
\frontmatter
\tableofcontents

\mainmatter
\chapter{a}
\section{b}
\subsection{c}
\subsubsection{d}

\end{document}

and your very same preamble (but moving hyperref to be the last package loaded) I get

enter image description here

By the way, the definition of \intd should be

\newcommand{\intd}{\mathop{}\!\textrm{d}}

No need of \ensuremath nor of using arguments.

2
  • Thank you so very much! That was the problem :) (Also that newcommand was just in the template by default, fortunately wasn't using it ;)) Commented Oct 31, 2019 at 16:28
  • 1
    Not at pc, but I would have expected \maxecnumdepth was needed because of mainmatter
    – daleif
    Commented Oct 31, 2019 at 17:24
3

The following MWE works on my system. The packages commented out, I do not have available. It is obviously that you do something another place on your system.

enter image description here

\documentclass[a4paper,10pt,oneside,openright]{memoir}

\usepackage{pdfpages}                           
\usepackage{fix-cm}                             
\usepackage[breaklinks,pdfpagelabels]{hyperref} % Move this to be the last package loaded
\usepackage[official]{eurosym}                  
\usepackage{subfig}                             
\usepackage[english]{babel}                     
\usepackage{wrapfig}
\usepackage{graphicx}                           
\usepackage{amsmath}                            
\usepackage{amssymb}                           
\usepackage{units}
%\usepackage{amsmath}
\usepackage[numbers,sort&compress]{natbib}      
%\usepackage{todonotes}
%\usepackage{ctable}                             
\usepackage{multirow}                           
\usepackage{xfrac}                              
%\usepackage{easytable}
%\usepackage{gensymb}

\usepackage{xcolor}

\setcounter{topnumber}{3}           
\setcounter{bottomnumber}{1}        
\setcounter{totalnumber}{4}       
\renewcommand{\topfraction}{0.8}    
\renewcommand{\bottomfraction}{0.8} 
\raggedbottom

\settypeblocksize{*}{14cm}{1.618}
\setlrmargins{3cm}{*}{*}
\setulmargins{3cm}{*}{*}
\checkandfixthelayout

\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\definecolor{darkgreen}{rgb}{0.0,0.3,0.0}
\hypersetup{        
    colorlinks,          % links are colored
    urlcolor=blue,       % color of external links
    linkcolor=darkblue,  % color of internal links
    citecolor=darkgreen, % color of links to bibliography
    bookmarksnumbered
}
\urlstyle{rm}

\newcommand{\intd}[1]{\ensuremath{\,\textrm{d}#1}}

\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{2}

\begin{document}

\part{1}
\chapter{2}
\section{3}
\subsection{4}

\end{document}
2
  • I honestly don't know what's going on then. I have also added my document assembly in my original post, but I have no layout definitions in those other chapters. I guess I'll have to find an alternative. Commented Oct 31, 2019 at 15:31
  • 1
    @PepijnEkelmans I forgot to move hyperref to be the last package to be loaded, and I was in a hurry, and had no available time to follow up yesterday. Good to see that ereg solved your problem.
    – Sveinung
    Commented Nov 1, 2019 at 6:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .