Clean chapter commands

This commit is contained in:
2024-09-27 22:37:45 +02:00
parent b793c55564
commit 90fbfec368
2 changed files with 28 additions and 27 deletions

View File

@@ -32,6 +32,31 @@
\setcounter{secnumdepth}{3} % Number subsubsections \setcounter{secnumdepth}{3} % Number subsubsections
% Parts and chapters
\NewCommandCopy{\oldchapter}{\chapter}
\RenewDocumentCommand{\chapter}{s o m}{% #1 = star (no number), #2 = short title, #3 = title
\IfBooleanTF{#1}{%
\oldchapter*{#3}% Starred chapter
\addcontentsline{toc}{chapter}{#3}% Add to the table of contents
}{%
\IfValueTF{#2}{%
\oldchapter[#2]{#3}% Chapter with short title
}{%
\oldchapter{#3}% Regular chapter
}%
\addcontentsline{lof}{chapter}{\thechapter.\ #3} % Add to the list of figures
\addcontentsline{lot}{chapter}{\thechapter.\ #3} % Add to the list of tables
}%
}
\newcommand{\importchapter}[2]{% Load a chapter (#2) in a path (#1)
\glsresetall% Reset the acronyms
\graphicspath{{#1/figures/}}% Enable relative paths for images
\cleardoublepage% Start on a right page
\includefrom{#1}{#2}% Include with relative paths \input in the chapter
}
% Headers % Headers
\usepackage{emptypage} % Remove headers and footers on empty pages \usepackage{emptypage} % Remove headers and footers on empty pages
\usepackage{etoolbox} % Patching commands \usepackage{etoolbox} % Patching commands

View File

@@ -1,30 +1,3 @@
% Chapters
\newcommand{\importchapter}[2]{% Load a chapter (#2) in a path (#1)
\glsresetall% Reset the acronyms
\graphicspath{{#1/figures/}}% Enable relative paths for images
\cleardoublepage% Start on a right page
\includefrom{#1}{#2}% Include with relative paths \input in the chapter
}
\NewCommandCopy{\oldchapter}{\chapter}
\RenewDocumentCommand{\chapter}{s o m}{% #1 = star (no number), #2 = short title, #3 = title
\IfBooleanTF{#1}{%
\oldchapter*{#3}% Starred chapter
\addcontentsline{toc}{chapter}{#3}% Add to the table of contents
}{%
\IfValueTF{#2}{%
\oldchapter[#2]{#3}% Chapter with short title
}{%
\oldchapter{#3}% Regular chapter
}%
\addcontentsline{lof}{chapter}{#3}% Add to the list of figures
%\addcontentsline{lot}{chapter}{#3}% Add to the list of tables
}%
}
\newcommand{\noindentskip}{\bigskip\noindent} % Skip a line and remove the indent
% Equations % Equations
\NewEnvironmentCopy{oldequation}{equation} \NewEnvironmentCopy{oldequation}{equation}
\RenewDocumentEnvironment{equation}{m}{% \RenewDocumentEnvironment{equation}{m}{%
@@ -118,6 +91,9 @@
\renewcommand{\secref}[2][\labelprefix]{Section~\ref{#1:#2}} \renewcommand{\secref}[2][\labelprefix]{Section~\ref{#1:#2}}
\renewcommand{\tabref}[2][\labelprefix]{Table~\ref{#1:tab:#2}} \renewcommand{\tabref}[2][\labelprefix]{Table~\ref{#1:tab:#2}}
% Misc
\newcommand{\noindentskip}{\bigskip\noindent} % Skip a line and remove the indent
% Tables % Tables
\RenewDocumentEnvironment{tab}{O{htbp} m m O{}}{% #1 = position, #2 = label, #3 = title, #4 = additional caption \RenewDocumentEnvironment{tab}{O{htbp} m m O{}}{% #1 = position, #2 = label, #3 = title, #4 = additional caption
\begin{table}[#1]% \begin{table}[#1]%