# TeXStudio does not recognize the \dominitoc \minitoc commands

I am having a weird problem when trying to produce a mini-toc in each of my chapters in a book I am doing.

I have full TeXLive distribution, and I run Linux. I used the terminal and ran the kpsewhich minitoc.sty to confirm it does have the minitoc package installed.

I can add \usepackage{minitoc} just fine, but when I try to add \dominitoc before my \tableofcontents command as you're supposed to, it shows up red and TeXStudio does not recognize it. Same happens when you try and add \minitoc after \chapter{}.

I have separate .tex files for each chapter and I am using \include (if that is relevant).

Has anyone experienced this on TeXStudio (5.9.5) on Linux (Ubuntu 18.04) yet?

These are the other packages I'm using:

\documentclass[a4paper,12pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{scrextend}
\usepackage{siunitx}
\usepackage[bottom]{footmisc}
\usepackage{mathtools}
\usepackage{enumitem}


Are some of them incompatible with minitoc perhaps?

It is doing something similar when I try to use the titletoc package instead. You can add the package just fine, but when you try to use the associated commands, it is unrecognized.

Edit: upon compiling, it does not produce the mini-toc. It does create auxiliary files though.

• That TeXstudio highlights something red does not necessarily mean that it won't work. It could just mean that TeXstudio doesn't load or doesn't have a .cwl file (auto completion file) for the package in question. See also tex.stackexchange.com/q/47493. If the document compiles without error you can just ignore it. – Torbjørn T. Sep 15 '19 at 20:58
• Yes, that's true. Unfortunately in my case though, it is not producing the minitoc at all. Thanks, I have edited my question to include this. – Adrian Sep 15 '19 at 21:01
• If I take your preamble, add the minitoc package at the end, and then \begin{document} \dominitoc \tableofcontents \chapter{f} \minitoc \section{b} \section{c} \end{document} I do get a minitoc. Does that work for you? Do you compile twice? – Torbjørn T. Sep 15 '19 at 21:09
• @Torbjørn T, yes tried that quickly, but didn't change anything. I think I have the answer perhaps, well, sort of. I have posted it. – Adrian Sep 15 '19 at 22:00

I have come to the conclusion that the fact TeXStudio doesn't recognize the command is not the issue here (as @Torbjørn T suggested), it compiles without any errors. I think the issue is it is assigning the wrong minitoc to the wrong chapters.

After looking through the auxiliary files, I noticed the following files:

• main.mtc
• main.mtc0
• main.mtc1
• main.mtc2
• main.mtc3
• main.mtc4
• main.mtc5

Now, when I open these files, I find main.mtc, main.mtc0, main.mtc1, main.mtc2 and main.mtc5 are empty. But, main.mtc3 and main.mtc4 have the sections of chapter 1 and chapter 2 in my book listed, respectively.

So, immediately I recalled someone who mentioned that they were getting the wrong minitoc for the wrong chapter: Minitoc of wrong chapter.

And the lightbulb went off. So I used the \adjustmtc command as was suggested in this case and I sort of managed to get a minitoc to show up for one of my chapters, but it's the wrong one for the chapter.

My structure is like this, I have:

• Front matter chapter (unnumbered)
• Front matter chapter (unnumbered)
• Chapter 1
• Chapter 2
• Back matter chapter (unnumbered)

I only have two main chapters. After inserting the \adjustmtc command after \tableofcontents, I get chapter 1's minitoc showing up at chapter 2. Messing around further by inserting \adjustmtc in other places brings forward chapter 2's minitoc to chapter 1 and similar things.

I have also tried \dominitoc right after \begin{document}, but that seems to be irrelevant.

The \adjustmtc command also has an argument [...] into which I typed 3 for chapter 1 and 4 for chapter 2, which produces the right minitoc for chapter 1 but no minitoc for chapter 2.

Tried inserting \listoffigures too as I will have one eventually, but didn't change much. So, I will continue to mess around with this and see what happens. This is a start I think.

Edit: got it right so far, by adding one \adjustmtc[2] directly after \tableofcontents and now the right minitoc is showing up at the right chapter. I think one can just keep adjusting the value in the argument. It must be the unnumbered chapters before chapter 1 that has something to do with it I guess. These obviously have no sections, hence produce a blank minitoc, which is then appearing as "nothing" at chapters that do have sections. At least it seems that way.

• Learned two more things - \listoffigures, \listoftables and using \chapter*{} does not seem to add to the chapter "count", and it seems you have to put \adjustmtc[<x>] right before the first minitoc-containing chapter. – Adrian Sep 16 '19 at 10:25