我正在编写一个带有article
类的文档,并使用 TexMaker/pdfLatex 对其进行编译。
我想为其创建一个本地目录,\appendix
但我不希望\section{}
之后\subsection{}
写的内容\appendix
显示在主目录中。
以下是一些屏幕截图来解释我的问题。我的代码位于以下两张图片下方。
\documentclass[12pt,oneside,a4paper]{article}
%\usepackage[left=1.7cm,right=1.8cm,top=1.8cm,bottom=1.7cm]{geometry}
\usepackage[total={210mm,297mm},left=23mm,right=15mm,top=20mm,bottom=20mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
%%%%glossary%%%%
\usepackage[automake]{glossaries}
\usepackage{glossary-mcols}
\makeglossaries
%%acronyms commands%%\\
\newacronym{mof}{MOF}{Metal-oragnic framework}
\newacronym{lmof}{LMOF}{Luminescent metal-oragnic framework}
\newacronym{ln-mof}{Ln-MOF}{Lanthanide-based metal-oragnic framework}
\newacronym{ln-salt}{Ln-S}{Lanthanide salt}
\newacronym{ln-ox}{Ln-Ox}{Lanthanide oxide}
\newacronym{t-14-chdca}{t-1,4-cHdCA}{trans-1,4-cyclohexane dicarboxylic acid}
\newacronym{4444-pyrene-tetrabenzoic-acid}{H4TBAPy}{4,4',4'',4'''-(pyrene-1,3,6,8-tetrayl)tetrabenzoic acid}
\newacronym{dmf}{DMF}{Dimethylformamide}
\newacronym{h-ac}{HAc}{Acetic acid}
\newacronym{voc}{VOC}{Volatile organic compound}
\newacronym{xrd}{XRD}{X-ray diffraction}
\newacronym{pxrd}{PXRD}{Powder X-ray diffraction}
\newacronym{tga}{TGA}{Thermogravimetric analysis}
\newacronym{sem}{SEM}{Scanning electron microscopy}
\newacronym{gs}{GS}{Gas sorption}
\newacronym{uv-vis-fluo-spectro}{UV-V/FS}{UV-Visible/fluorescence spectroscopy}
\newacronym{uv-vis-spectro}{UV-VS}{UV-Visible spectroscopy}
\newacronym{fluo-spectro}{FS}{Fluorescence spectroscopy}
%\acrshort{ } ; \acrlong{ } ; \acrfull{ }
%%couleurs
\usepackage[table,dvipsnames]{xcolor}
%\definecolor{dark green}{RGB}{46,191,39}
%%%%maths and tikz
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
%%%%units
\usepackage{siunitx}
\sisetup{inter-unit-product=\ensuremath{{}\cdot{}}}
%%%%chemistry
\usepackage{chemfig}
\usepackage{chemnum}
\usepackage{chemmacros}
\chemsetup{modules=all}
%\usepackage[en]{pgf-PeriodicTable}
%%%%boxes
\usepackage{awesomebox}
\usepackage{fontawesome5}
\usepackage[most]{tcolorbox}
\usepackage{fancybox}
%table and tabular
\usepackage{longtable}
\usepackage{tabulary}
\usepackage{fancybox}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}
\renewcommand{\arraystretch}{1.17}
%\newcolumntype{a}[1]{>{\columncolor{red!30}}l}
\newcolumntype{C}[1]{>{\centering \arraybackslash}m{#1}}
%%%%references
\usepackage{hyperref}
\renewcommand\thefootnote{\textcolor{black}{\arabic{footnote}}}
\renewcommand\thefigure{\textcolor{blue}{\arabic{figure}}}
%\renewcommand\thesubfigure{(\alph{subfigure})} don't work
\renewcommand\thetable{\textcolor{magenta}{\arabic{table}}}
%%%%lists
\usepackage{enumerate}
\usepackage{enumitem}
\newlist{todolist}{itemize}{2}
\setlist[todolist]{label=$\square$}
%\newlist{notes}{enumerate}{1}
%\setlist[notes]{label=\textsl{Note:} ,leftmargin=1.4cm}
%%%%multi column
\usepackage{multicol}
%% page style and format
\usepackage[document]{ragged2e} % justifie sans interligne au debut
\usepackage{fancyhdr}
\pagestyle{fancy}
%%%%figures
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{wrapfig}
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext=loaf,
listname={Appendices figures},
name=Figure,
placement=tp,
%within=section,% activate it if you want
%chapterlistsgaps=on,% only meaningful when chapters exist
]{appendixfigure} %for list of figure in appendices sections
\DeclareCaptionType{appendixtable}[Table][Appendices tables] %for list of table appen.
%%%%table of contents and list of
\usepackage{titletoc}
\usepackage{etoc}
\addto\captionsenglish{\renewcommand{\contentsname}{Table of contents}}
\usepackage{tocloft}
%liste equations
\newcommand{\listequationsname}{\Large{List of equations}}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.3em}
\setlength{\cftmyequationsindent}{1.5em}
%%condition analyse competences
\newcommand\conform{} %avec lettre => affichage, sans P n'affiche pas
\newcommand\perso[1]{
\if
\conform P {#1}
\else{}
\fi
}
\newcommand\CONFORM{}
\newcommand\tuteur[1]{
\if
\CONFORM T {#1}
\else{}
\fi
}
%%acknoledgements style (same as default abstract style)
\newenvironment{acknowledgements}{%
\renewcommand{\abstractname}{Acknowledgements} % rename Abstract to Acknowledgements
\begin{abstract}
}{%
\end{abstract}
}
%%specifications (cahier des charges)
\newenvironment{specifications}{%
\renewcommand{\abstractname}{Specifications}
\begin{abstract}
}{%
\end{abstract}
}
%%orienter 1 page en paysage
\usepackage{pdflscape}
%% appendix
\usepackage[toc,page,header]{appendix}
\newcommand{\stoptocwriting}{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{-5}}}
\newcommand{\resumetocwriting}{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{\arabic{tocdepth}}}}
%%%%%%%%%%%%%%
\begin{document}
%\nocite{*} %pour ne pas citer les ref à chaque fois
%\startcontents[sections]
%\printcontents[sections]{l}{1}{\setcounter{tocdepth}{2}}
\begin{titlepage}
\begin{flushleft}
\begin{minipage}{1\textwidth}
\begin{multicols}{2}
\begin{flushleft}
\includegraphics[scale=0.61]{../../../../../../Pictures/index.png} \\
\begin{small}
D\'epartement Mat\'eriaux \\
Polytech Marseille, Campus Luminy \\
163 avenue de Luminy, case 925 \\
13288 Marseille Cedex 09 \\
France
\end{small}
\end{flushleft}
\begin{flushright}
\includegraphics[scale=0.75]{../lab presentations/25 mai/uppsala_university_logo.png} \\
\vspace{-0.2em}
\begin{small}
Department of Materials Science and Engineering
\AA{}ngstr\"omlaboratoriet, Uppsala University
L\"agerhyddsv\"agen1 \\
Uppsala 75237 \\
Sweden
\end{small}
\end{flushright}
\end{multicols}
\end{minipage}
\end{flushleft}
\vspace*{0.75cm}
\begin{center}
\shadowbox{
\begin{minipage}{0.83\textwidth}
\begin{center}
\begin{LARGE}
Luminescent metal-organic frameworks for \\
the detection of volatile organic compounds
\end{LARGE}
\end{center}
\end{minipage}}
\end{center}
\vspace*{0.25cm}
\begin{center}
\begin{figure}[!h]
\centering
\includegraphics[scale=0.23]{mof example.png}
\end{figure}
\end{center}
\begin{center}
stage r\'ealis\'e du 2 mai 2023 au 27 juillet 2023 \\
par Tony xxxxx \\
\'el\`eve ing\'enieur mat\'eriaux \\
$4^{\mathrm{e}}$ ann\'ee $-$ promotion 2024
\end{center}
\vspace*{0.75cm}
\begin{flushleft}
Tuteur-Entreprise : M. xxxxx xxxxx \\
Tuteur-\'Ecole : ....
\end{flushleft}
\vspace*{1.0cm}
\begin{center}
\underline{Confidentialit\'e} \\
$ $ \\
\fbox{
\begin{minipage}{0.95\textwidth}
Les informations contenues dans ce livrable ne pr\'esentent pas de caract\`ere confidentiel.
\end{minipage}
}
\end{center}
\end{titlepage}
\newpage
\renewcommand{\headrulewidth}{0mm}
\renewcommand{\footrulewidth}{0mm}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{}
\fancyhead[C]{}
\fancyhead[R]{}
\fancyfoot[L]{} %\tiny\insert\footins
\fancyfoot[C]{}
\fancyfoot[R]{\thepage}
\setcounter{page}{1}
\tableofcontents
\newpage
\begin{abstract}
text
\end{abstract}
\vspace*{0.6cm}
\centerline{\rule{9cm}{0.8pt}}
\vspace*{0.6cm}
\begin{acknowledgements}
This project was carried out from May 2023 to July 2023 and supervised by Mr. xxxxx xxxxx and Ms. xxxxx xxxxxx. The ressources, equiment and glassware used to carry out this project belong to \AA{}ngstr\"omlaboratoriet (lab of Uppsala university).
\end{acknowledgements}
\vspace*{0.6cm}
\centerline{\rule{9cm}{0.8pt}}
\vspace*{0.6cm}
\addcontentsline{toc}{section}{Specifications}
\begin{specifications}
%\begin{tcolorbox}[colback=blue!5!white,colframe=blue!85!black,title=\large{Tasks to be completed}]
This project deals with synthesing and characterizing lanthanide-based \acrshort{mof}s to investigate if these materials can be used as platforms for detecting selected \acrshort{voc}s. \\
The tasks to be completed are listed below.
\begin{enumerate}[label=\textbullet]
\item Read literature on \acrshort{mof}s
\item Plan the experimental work
\item Carry out the syntheses of different lanthanide-based \acrshort{mof}s
\item Characterize each synthesized \acrshort{mof} (\acrshort{xrd}, \acrshort{sem}, \ldots)
\item Investigate the porosity, stability, and luminescent properties of the synthesized \acrshort{mof}s
\end{enumerate}
%\tcblower
%text below dashed line
%\end{tcolorbox}
\end{specifications}
\clearpage
\renewcommand{\headrulewidth}{0.3mm}
\renewcommand{\footrulewidth}{0mm}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{}
\fancyhead[C]{}
\fancyhead[R]{\leftmark}
\fancyfoot[L]{} %\tiny\insert\footins
\fancyfoot[C]{\thepage}
\fancyfoot[R]{}
\section{Introduction}
text
%\newpage
%\listoffigures
%\vspace*{2.5cm}
%\listoftables
%\listofmyequations
%\newpage
%\addcontentsline{toc}{section}{Acronyms}
\printglossary[style=mcolindex,title=Acronyms]
\label{acronyms}
%%%%%%%%%%%%%%%%%%%APPENDICES%%%%%%%%%%%%%%%%%
\clearpage
\renewcommand{\headrulewidth}{0.3mm}
\renewcommand{\footrulewidth}{0mm}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{}
\fancyhead[C]{}
\fancyhead[R]{\appendixname}
\fancyfoot[L]{} %\tiny\insert\footins
\fancyfoot[C]{\thepage}
\fancyfoot[R]{}
\renewcommand{\contentsname}{Appendix Contents}
\renewcommand{\appendixname}{Appendices}
\appendix
\appendixpage
%\stoptocwriting
\startcontents[appendix]
\printcontents[appendix]{}{2}{\setcounter{tocdepth}{2}}
\section{appendix test}
\subsection{test}
text
\end{document}
答案1
\parttoc
这使用 minitoc为附录创建目录 ( )。它用于\addtocontents
关闭列表中间的原始目录。通常 minitoc 需要一个\part
命令来启动\parttoc
,但我能够使用 来伪造它\stepcounter{ptc}
。
\documentclass{article}
\usepackage{appendix}
\usepackage{minitoc}
\begin{document}
\doparttoc
\tableofcontents
\newpage
\section{Introduction}
Some text.
\newpage
\appendix
\appendixpage
\addappheadtotoc
\addtocontents{toc}{\string\setcounter{tocdepth}{0}}% stop listing sections
\stepcounter{ptc}% activate parttoc
\parttoc
\newpage
\section{test}
\subsection{test}
Some text
\end{document}
答案2
以下代码不显示2个目录,而只显示一个!
\documentclass{article}
\usepackage{appendix}
\usepackage{minitoc}
\begin{document}
\doparttoc
\dopartlof
\dopartlot
\tableofcontents
\newpage
\section{Introduction}
Some text.
\begin{figure}[h!]
\centering
h
\caption{test}
\end{figure}
\begin{table}[h!]
\centering
\begin{tabular}{ll}
hello & there \\
\end{tabular}
\caption{tester}
\end{table}
\newpage
\listoffigures
\listoftables
\newpage
\appendix
\appendixpage
\addappheadtotoc
\addtocontents{toc}{\string\setcounter{tocdepth}{0}}% stop listing sections
\stepcounter{ptc}% activate parttoc
\parttoc
\partlof
\partlot
\newpage
\section{test}
\subsection{test}
Some text
\begin{figure}[h!]
\centering
h
\caption{test}
\end{figure}
\begin{table}[h!]
\centering
\begin{tabular}{ll}
hello & there \\
\end{tabular}
\caption{test}
\end{table}
\end{document}
[![在此处输入图片说明][1]][1] [![在此处输入图片说明][2]][2]
与 \appendix 关联的 \parttoc 未按预期显示。我该如何解决这个问题?[1]:https://i.stack.imgur.com/wx6lg.png [2]:https://i.stack.imgur.com/Bz3j6.png