1

I use the memoir class in writing an abstract and use only sections and subsections and got an empty table of contents. How do I fix this? I did like here: memoir without chapters but it didn't help.

My code:

\documentclass[a4paper,14pt,article,oneside,openany]{memoir}

% --------------------------------------------------------

\usepackage{geometry}
\geometry{left=25mm,right=10mm,top=20mm,bottom=20mm,nofoot,nomarginpar}
\setlength{\topskip}{0pt}
\setlength{\footskip}{12.3pt}
%%% Колонтитулы %%%
\makeevenhead{plain}{}{}{}
\makeoddhead{plain}{}{}{}
\makeevenfoot{plain}{}{\thepage}{}
\makeoddfoot{plain}{}{\thepage}{}
\pagestyle{plain}
%------------------------------
\usepackage[final]{microtype} % межсимовольный рендеринг, борящийся с оверфуллами

\usepackage[no-math]{fontspec}
\setmainfont{STIX2Text}[
    Path           = ./fonts/STIXv2.0.2/ ,
    UprightFont    = *-Regular ,
    BoldFont       = *-Bold ,
    ItalicFont     = *-Italic ,
    BoldItalicFont = *-BoldItalic ]

\usepackage{unicode-math}
\setmathfont{STIX2Math}[
    Path = ./fonts/STIXv2.0.2/ ]

\usepackage[english,russian]{babel}
\usepackage[labelsep=period,labelfont=bf,figurename={Рис.},figurewithin=none]{caption}
\usepackage{cite}
\usepackage{enumerate}
\usepackage{float}
\usepackage{graphicx}
\usepackage{indentfirst}

\OnehalfSpacing* %полуторный интервал для всего текста
\renewcommand\tableofcontents{\large {\textbf{Содержание}}} %%% переименовали оглавление в memoir на содержание
% --------------------------------------------------------
\counterwithout{section}{chapter}

\begin{document}

\input{title}

\newpage
\tableofcontents
\newpage

\input{introduction}
\input{theory}
\input{methods}
\input{high_frequency}
\input{conclusion}
\end{document}
8
  • 1
    Please make sure your example is self contained, you input stuff we don't have access to
    – daleif
    Oct 7, 2020 at 18:28
  • There is a good chance that the line \renewcommand\tableofcontents{\large {\textbf{Содержание}}} is at fault here since you ask \tableofcontents to just print a word. What you want is to do \renewcommand{\contentsname{Содержание}}
    – KersouMan
    Oct 7, 2020 at 18:35
  • just for example: ru.overleaf.com/6739953172hwfccyttkfny
    – Fidelity
    Oct 7, 2020 at 18:44
  • I edit by your @KersouMan example and the compiler returned an error: command \contentsname{Содержание} undefined.
    – Fidelity
    Oct 7, 2020 at 18:52
  • 1
    We can't quite tell what you did because you didn't use TeX.SE formatting. Regardless, it's better to post your answer as an answer, so that it can be voted on.
    – Teepeemm
    Oct 7, 2020 at 20:05

4 Answers 4

0

If I understand your self answer correctly, you just want to use nu-numbered sections and still have their title show up in the TOC?

That is easy with memoir

\setsecnumdepth{none}
\maxsecnumdepth{none} % due to \mainmatter

and then use \section and friends as normal.

1
  • Thank you for your response, simple and working code.
    – Fidelity
    Oct 8, 2020 at 13:16
0

If you want to use memoir with only section and below then use it with the article option, whereby \chapter is set at \section, \section is set as \subsection, etc.

Thank you for your MWE which didn't work for me as I didn't have the font you were using. Here is a very stripped down version of your MWE which does not typeset chapters and gives a ToC.

% memtocprob.tex SE 565843
\documentclass[a4paper,14pt,article,oneside,openany]{memoir}

%\usepackage[english,russian]{babel}
\begin{document}

%\input{title}

\newpage
\tableofcontents*
\newpage

%\section{Introduction} %\input{introduction}
\chapter{Introduction}
Introductory text.
\section{Stuff}
More text.
%\input{theory}
%\input{methods}
%\input{high_frequency}
%\input{conclusion}
\end{document}

However, if you uncomment the \usepackage[english,russian]{babel} then no ToC is produced. The problem lies in the use of the babel package which I have never used.

6
  • It remains a mystery to me why such a powerful the memoir class is not optimized for working with babel?
    – Fidelity
    Oct 8, 2020 at 8:54
  • @user226232 we cannot control what babel and its languages does or when users misuse macros that clearly should only contain text. I have no issues with Peters example on an up to date TL20 once russian fonts have been generated.
    – daleif
    Oct 8, 2020 at 10:05
  • @PeterWilson what does your system do when that babel line is used? After mine finished generating russian bitmap fonts I have a toc with a russian header and two items written in English
    – daleif
    Oct 8, 2020 at 10:06
  • thank you for your answer, I made a code based on your example.
    – Fidelity
    Oct 8, 2020 at 12:55
  • @daleif I have emailed you seperately about this, but essentially I don't have the russian font. Oct 8, 2020 at 17:11
0

The problem was solved by the method suggested here: https://stackoverflow.com/a/4002358

\newcommand{\huection}[1]{%
    \section*{#1}%
    \addcontentsline{toc}{section}{#1}%
}

\maxtocdepth{subsection}
\newcommand{\subhuection}[1]{%
    \subsection*{#1}%
    \addcontentsline{toc}{subsection}{#1}%
}

I replaced all \section with \huection and all \subsection with \subhuection.

1
  • So you only have un-numbered sections? Then we can do something easier, \setsecnumdepth{none}\maxsecnumdepth{none} and then you can just use \section as normal. It is not easy to figure out your intensions from your example when you don't show us code you can use.
    – daleif
    Oct 8, 2020 at 9:12
0

You do not need newcommands, nor the \counterwithout{section}{chapter} tricks.

Using the article option \chapters are like section, so you only have to replace \section by \chapter and \subsection by \section and so on with sublevel, if thre are some.

Note that starred versions of sectioning commands (\chapter*, \sections*, etc.) are designed to (1) be unnumbered and (2) do dot appear in the ToC.

If you want only not numbered headers modify secnumdepth (as daleif pointed, in memoir you can use \setsecnumdepth and \maxsecnumdepth for this, see section 6.3 of the memoir's manual) and to show these in the ToC setting tocdepth properly: Example using the standard \setcounter:

\documentclass[article]{memoir}
\setcounter{secnumdepth}{-2}
\setcounter{tocdepth}{5}
\begin{document}
\tableofcontents{}
\chapter{foo} The (fake) section
\section{bah} The (fake) subsection
\end{document}

In case that you want mix numbered and unnumbered chapters and sections in the ToC, use the starred and not starred versions and \addcontentsline as needed. Example:

\documentclass[article]{memoir}
\begin{document}
\tableofcontents{}
\chapter{foo} The (fake) section
\section{bah} The (fake) subsection
\addcontentsline{toc}{chapter}{baz}
\chapter*{baz} Another  (fake) section
\addcontentsline{toc}{section}{buf}
\section*{buf} Another  (fake) subsection
\end{document}
1
  • Thank you for your response, this code really works.
    – Fidelity
    Oct 8, 2020 at 12:56

You must log in to answer this question.

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