I am writing my thesis using LaTeX and I would like to include at the beginning of each chapter a mini table of contents including only sections. I am using the minitoc package which I declare in my preamble file. In my main file, I found myself obliged to include the following for the the minitoc to update itself:
% *********************** Adding TOC and List of Figures ***********************
\dominitoc
\tableofcontents
\listoffigures \mtcaddchapter
\listoftables \mtcaddchapter
As I am setting the section counter to 2:
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
The mini tables of contents I am getting includes the subsections (which seems the default minitoc section depth). I tried changing the section toc depth by including:
\newcounter{secttocdepth}
\setcounter{secttocdepth}{1}
everywhere with no success. Your help is very welcome!
Have you tried using
\setcounter{minitocdepth}{1}
like described by the minitoc manual
Related
I was given a Latex project as template and I decided to add a glossary on it, however, \printglossary is not working. I can add and use different entries so I guess that the glossary creation is not the problem.
I am using Overleaf and if I try a completely new project with only the glossary (code bellow) \printglossary works fine.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronym, toc]{glossaries}
\makeglossaries
\input{Bibliocosas/glossary.tex}
\begin{document}
\tableofcontents
\section{First Section}
The \Gls{latex} typesetting markup language is specially suitable for documents that include \gls{maths}. \Glspl{formula} are rendered properly an easily once one gets used to the commands.
\clearpage
\section{Second Section}
\vspace{5mm}
Given a set of numbers, there are elementary methods to compute its \acrlong{gcd}, which is abbreviated \acrshort{gcd}. This process is similar to that used for the \acrfull{lcm}.
\clearpage
\printglossary
\clearpage
\printglossary[type=\acronymtype]
\end{document}
I am using chapters intead of sections in the given project, is that the the cause of the problem?
Using \makenoidxglossaries and \printnoidxglossaries seems to apparently solve the problem.
I thought that I had already tried them but I guess I was wrong. However, I still don't know why the previous code does not work in the given project.
As for me, I had the same issue but I fixed it by using glossaries-extra package after glossaries package using.
\usepackage[automake]{glossaries-extra}
Then clearing the cache.
I had this issue with Overleaf. The problem was that I uploaded the project as a zip and Overleaf created an additional nested directory in the root with the name of my project. Everything worked but not glossaries.
To solve this I just moved all files to the root directory by dragging each of it.
How could I number the tables in my article chapter based ? So I want all the tables in the fifth section to be numbered like "Table 5.1", ..., "Table 5.n".
I tried
\usepackage{chngcntr}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\counterwithin{equation}{section}
but I am having some problems (missing package I guess).
However, I need a simpler solution, without the need to use such packages.
The article class doesn't have chapters. Try the book or report classes - you'll find that the tables and figures are automatically numbered according to chapter.
Here is a solution without the use of any package (courtesy of "The Latex Companion", A1.4):
\makeatletter
\renewcommand{\thetable}{\thesection.\#arabic\c#table}
\#addtoreset{table}{section}
\makeatother
This resets the table counter whenever a new section is started, and formats it as sectionno.tableno instead of just tableno. You can change the figure and equation counters similarly.
If you are using the amsmath package (or an AMS class like amsart that loads it automatically), you can use
\numberwithin{table}{section}
This was created for equations, but works for any pair of counters though supposedly there might be tricky situations that it does not handle well.
I'm writing a short document using sections rather than chapters as the top-level (documentclass report). However,
\bibliographystyle{amsplain}
\bibliography{general}
causes the bibliography to be inserted as a chapter rather than a section. Is there any way to change this?
By default, the report document class uses \chapter as the bibliography heading level. In contrast, the article document class uses \section as the bibliography heading level. If you're not using \chapter anywhere in your document, you might want to use the article class instead.
If you really want to use the report class, you'll need to redefine the thebibliography environment to use \section instead of \chapter. In the preamble of your document (after the \documentclass line but before the \begin{document} line, insert the following:
\makeatletter
\renewenvironment{thebibliography}[1]
{\section*{\bibname}% <-- this line was changed from \chapter* to \section*
\#mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
\list{\#biblabel{\#arabic\c#enumiv}}%
{\settowidth\labelwidth{\#biblabel{#1}}%
\leftmargin\labelwidth
\advance\leftmargin\labelsep
\#openbib#code
\usecounter{enumiv}%
\let\p#enumiv\#empty
\renewcommand\theenumiv{\#arabic\c#enumiv}}%
\sloppy
\clubpenalty4000
\#clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\#m}
{\def\#noitemerr
{\#latex#warning{Empty `thebibliography' environment}}%
\endlist}
\makeatother
Now your bibliography will have a \section heading instead of a \chapter heading.
Note that if you load any special bibliography packages, you might want to put this code before those packages are loaded (so you don't overwrite their work).
Look at the package tocibind;
\usepackage[numbib,notlof,notlot,nottoc]{tocbibind}
numbib ensures the Bibliography gets numbered, while the not*-options disables showing the List of Figures, Tables and the TOC itself, respectively.
In my case, I also changed #godbyk's solution to include the section number.
#godbyk's line:
{\section*{\bibname}% <-- this line was changed from \chapter* to \section*
My line:
{\section{\bibname}% <-- this line was changed from \chapter* to \section
For having references at the chapter level, one can use: \addcontentsline{toc}{chapter}{References}.
To have them at the section level, one can use:\addcontentsline{toc}{section}{References}
I have a section followed by a table of contents like so:
\section{Section1}
ABC.
\addcontentsline{toc}{section}{Table of Contents}
\tableofcontents
\newpage
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\newpage
\section{Section2}
DEF.
\section{Section3}
GHI.
My issue is that the "Table of Contents" and "List of Figures" entries in the table of contents link (in the generated pdf) to the wrong place in the file. They both link to the first section section on page 1. The entry in the table is correct (TOC says page 2 and LOF says page 3), but the link goes to the wrong place.
You'll need to use the \phantomsection command:
\section{Section1}
ABC.
\phantomsection
\addcontentsline{toc}{section}{Table of Contents}
\tableofcontents
\newpage
\phantomsection
\addcontentsline{toc}{section}{List of Figures}
\listoffigures
\newpage
\section{Section2}
DEF.
\section{Section3}
GHI.
See the hyperref manual.
If you're doing this for the bibliography, list of tables or list of figures,
\usepackage[nottoc]{tocbibind}
should fix it, without the wrong-page problems. Otherwise, I havent come across a better solution than \phantomsection with \addcontentsline.
This behavior is due to the fact that \tableofcontents inserts a page break before writing the contents. Hence, your PDF bookmark will point to the page before. Depending on your document class, you can manually insert a number of \newpage commands to keep \tableofcontents from adding another. One or two should be sufficient.
I know, it is a hacky solution, and there might exist a package to solve the problem, but this is how I work around the problem.
In my LaTeX document I've got a table of contents that is automatically generated by collecting everything that is of the form \chapter.
However, I've got an acknowledgements chapter before the table of contents and I don't want it to be automatically labelled "Chapter 1" or captured in the table of contents. Should I be avoiding \chapter altogether and use \section instead? I want to keep the font/formatting that other chapters have though.
The usual way to handle that kind of thing is with the \frontmatter command. Put it after the \begin{document}, and then put \mainmatter right before the \chapter you want to correspond to chapter 1. This may only work in the book class. If you're using \chapter in a report, then \chapter* should also create a chapter that has no number and won't show up in the table of contents.
Indeed, as unknown (google) mentioned, using \frontmatter and \mainmatter is the best solution. This will also adjust your page numbering to lowercase roman numerals for the front matter. However, it works only on book and similar document classes.
In case you're using report, try \chapter*. This will create a chapter without a number that does not appear in the table of contents.
For articles \chapter* does not appear to work. Instead use \section*.