minitoc 包不起作用

minitoc 包不起作用

我尝试为一些章节插入迷你目录,但是没有成功。

% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
  11pt,
]{scrbook}

\usepackage[nottoc]{tocbibind}  % Package to include lists in ToC, excluding ToC itself
\usepackage{minitoc}                        % package to include toc's for each chapter

\usepackage{amsmath,amssymb}
\usepackage{setspace}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else  
    % xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage[left = 25mm, right = 25mm, top = 30mm, bottom =
30mm]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
  \let\oldparagraph\paragraph
  \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
  \let\oldsubparagraph\subparagraph
  \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi


\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
 {% don't indent paragraphs
  \setlength{\parindent}{0pt}
  % turn on hanging indent if param 1 is 1
  \ifodd #1
  \let\oldpar\par
  \def\par{\hangindent=\cslhangindent\oldpar}
  \fi
  % set entry spacing
  \setlength{\parskip}{#2\cslentryspacingunit}
 }%
 {}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}

\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}

\ohead{\headmark} % Überschrift 1 im äußeren Kopf
\automark[chapter]{chapter} % Kapitel auf beiden Seiten im header
\setheadsepline{0.4pt} % Linie unter der Kopfzeile
\setfootsepline{0.4pt} % Linie über der Fußzeile
\makeatletter
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
  \renewcommand*\contentsname{Inhaltsverzeichnis}
\else
  \newcommand\contentsname{Inhaltsverzeichnis}
\fi
\ifdefined\listfigurename
  \renewcommand*\listfigurename{Abbildungsverzeichnis}
\else
  \newcommand\listfigurename{Abbildungsverzeichnis}
\fi
\ifdefined\listtablename
  \renewcommand*\listtablename{Tabellenverzeichnis}
\else
  \newcommand\listtablename{Tabellenverzeichnis}
\fi
\ifdefined\figurename
  \renewcommand*\figurename{Abbildung}
\else
  \newcommand\figurename{Abbildung}
\fi
\ifdefined\tablename
  \renewcommand*\tablename{Tabelle}
\else
  \newcommand\tablename{Tabelle}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{Listingverzeichnis}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\makeatother
\makeatletter
\@ifundefined{shadecolor}{\definecolor{shadecolor}{rgb}{.97, .97, .97}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\makeatother
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{ngerman}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
  pdftitle={not used},
  pdfauthor={not used},
  pdflang={de},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}

\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
  \apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother
\date{2024-02-05}

\begin{document}
  \begin{frontmatter}
        \begin{titlepage}
            
  %----------------------------------------------------------------------------------------
  % PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
  %----------------------------------------------------------------------------------------


    \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for horizontal lines, change thickness here
    
    \center % Centre everything on the page
    
        %------------------------------------------------
    %   Logo
    %------------------------------------------------
        
    \includegraphics[width=1.8in]{./Bilder_Titelseite/Bild.png}\\[0.8cm]
    
    %------------------------------------------------
    %   Headings
    %------------------------------------------------
    
    \textsc{\Large project-name}\\[0.4cm] % Major heading such as course name
    
    \textsc{\large projecct-subname}\\[0.8cm] % Minor heading such as course title
    
    %------------------------------------------------
    %   Title
    %------------------------------------------------
    
    \HRule\\[0.3cm]
    
    {\huge\bfseries title}\\[0.3cm] % Title of your document
    
    \HRule\\[0.8cm]
    
    %------------------------------------------------
    %   Author(s)
    %------------------------------------------------
    
    \begin{minipage}{0.4\textwidth}
        \begin{flushleft}
            \large
            Mr example
        \end{flushleft}
    \end{minipage}
    ~
    \begin{minipage}{0.4\textwidth}
        \begin{flushright}
            \large
            Mrs example
        \end{flushright}
    \end{minipage}\\[1cm]
    
        
    %------------------------------------------------
    %   Titelbild
    %------------------------------------------------
    \includegraphics[height=3in]{./Bilder_Titelseite/Titelbild.png}\\[0.8cm]
        
    %------------------------------------------------
    %   Date
    %------------------------------------------------
        
    {\large\today} % Date, change the \today to a set date if you want to be precise
    
    %----------------------------------------------------------------------------------------
                \end{titlepage}
        \chapter{}

\center % Centre everything on the page
    
\includegraphics{Bilder_Titelseite/Foerderung.png}\\[2cm]

Die Verantwortung für den Inhalt dieser Veröffentlichung liegt bei
den Autoren.

\thispagestyle{empty}  \end{frontmatter}

  \ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[frame hidden, boxrule=0pt, sharp corners, breakable, enhanced, interior hidden, borderline west={3pt}{0pt}{shadecolor}]}{\end{tcolorbox}}\fi

\renewcommand*\contentsname{Inhaltsverzeichnis}
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\listoffigures
\listoftables
\setstretch{1.5}
\mainmatter

\dominitoc % necessary to include minitocs

\hypertarget{einfuxfchrung}{%
\chapter{Einführung}\label{einfuxfchrung}}

\hypertarget{kurzdarstellung}{%
\chapter{Kurzdarstellung}\label{kurzdarstellung}}

\minitoc

\hypertarget{aufgabenstellung-und-wesentliche-randbedingungen}{%
\section{Aufgabenstellung und wesentliche
Randbedingungen}\label{aufgabenstellung-und-wesentliche-randbedingungen}}

\hypertarget{planung-und-ablauf-des-vorhabens}{%
\section{Planung und Ablauf des
Vorhabens}\label{planung-und-ablauf-des-vorhabens}}

\hypertarget{arbeitsinhalte}{%
\subsection{Arbeitsinhalte}\label{arbeitsinhalte}}

\hypertarget{meilensteine}{%
\subsection{Meilensteine}\label{meilensteine}}

\hypertarget{literaturverzeichnis}{%
\chapter*{Literaturverzeichnis}\label{literaturverzeichnis}}
\addcontentsline{toc}{chapter}{Literaturverzeichnis}

\hypertarget{refs}{}
\begin{CSLReferences}{0}{0}
\end{CSLReferences}

\appendix
\renewcommand{\thechapter}{\Alph{chapter}}
\setcounter{chapter}{0}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}

\hypertarget{anhang-1}{%
\chapter{Anhang 1}\label{anhang-1}}

\setcounter{page}{1}
\renewcommand{\thepage}{\thechapter.\arabic{page}} % Seitenzahlformat ändern

\hypertarget{unterhang}{%
\section{Unterhang}\label{unterhang}}

\hypertarget{tbl-letters-full}{}
\begin{longtable}[]{@{}llll@{}}
\caption{\label{tbl-letters-full}1st Appendix table}\tabularnewline
\toprule\noalign{}
Col1 & Col2 & Col3 & Col4 \\
\midrule\noalign{}
\endfirsthead
\toprule\noalign{}
Col1 & Col2 & Col3 & Col4 \\
\midrule\noalign{}
\endhead
\bottomrule\noalign{}
\endlastfoot
A & B & C & D \\
E & F & G & H \\
I & J & K & L \\
M & N & O & P \\
Q & R & S & T \\
U & V & W & X \\
Y & Z & - & - \\
\end{longtable}

\newpage{}

test

\newpage{}

test

\hypertarget{anhang-2}{%
\chapter{Anhang 2}\label{anhang-2}}

\setcounter{page}{1}

\hypertarget{tbl-letters2-full}{}
\begin{longtable}[]{@{}llll@{}}
\caption{\label{tbl-letters2-full}2nd Appendix table}\tabularnewline
\toprule\noalign{}
Col1 & Col2 & Col3 & Col4 \\
\midrule\noalign{}
\endfirsthead
\toprule\noalign{}
Col1 & Col2 & Col3 & Col4 \\
\midrule\noalign{}
\endhead
\bottomrule\noalign{}
\endlastfoot
A & B & C & D \\
E & F & G & H \\
I & J & K & L \\
M & N & O & P \\
Q & R & S & T \\
U & V & W & X \\
Y & Z & - & - \\
\end{longtable}

\newpage{}

test

\newpage{}

test


\backmatter

\end{document}

答案1

我修复了这个问题。我已采取titletoc以下措施minitoc

...
\usepackage{titletoc} % package for chapter-toc
\usepackage{fancybox} % package for fancy-box

% chapterwise table of contents
{
    \titlecontents{chapter}% <section-type>
    [0pt]% <left>
    {}% <above-code>
    {\bfseries\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
    {}% <numberless-entry-format>
    {\bfseries\contentspage}% <filler-page-format>
}

% fancy box for the chapter-toc
\newcommand{\chaptertocbox}[1]{%
    \setlength{\fboxrule}{0.4mm}%
    \setlength{\fboxsep}{3mm}%
    \cornersize{0.2}%
    \Ovalbox{%
        \hspace{-1em}% Einrückung auf der linken Seite
        \parbox{\dimexpr\textwidth-2\fboxsep-2\fboxrule}{%
            #1% Inhalt
        }%
    }%
}
...
\hypertarget{kurzdarstellung}{%
\chapter{Kurzdarstellung}\label{kurzdarstellung}}

% start the chapter toc command
\startcontents[chapters]
\noindent
\chaptertocbox{\printcontents[chapters]{}{1}{}}

\hfill\break
\hfill\break

In diesem Kapitel werden Aufgabenstellung und wesentliche
Randbedingungen des Projekts vorgestellt. Ebenso wird auf die Planung
und den Ablauf des Vorhabens eingegangen. Es werden Arbeitsinhalte und
Meilensteine vorgestellt.

\newpage{}

\hypertarget{aufgabenstellung-und-wesentliche-randbedingungen}{%
\section{Aufgabenstellung und wesentliche
Randbedingungen}\label{aufgabenstellung-und-wesentliche-randbedingungen}}

\hypertarget{planung-und-ablauf-des-vorhabens}{%
\section{Planung und Ablauf des
Vorhabens}\label{planung-und-ablauf-des-vorhabens}}

\hypertarget{arbeitsinhalte}{%
\subsection{Arbeitsinhalte}\label{arbeitsinhalte}}

\hypertarget{meilensteine}{%
\subsection{Meilensteine}\label{meilensteine}}

% end the chapter toc command
\stopcontents[chapters]
...

相关内容