Format commands

This commit is contained in:
2024-09-29 14:09:39 +02:00
parent d5956ad176
commit ab13ad3d9a

View File

@@ -1,7 +1,6 @@
%% Packages required %% Packages required
\usepackage[caption=false]{subfig} % Good looking subfigs \usepackage[caption=false]{subfig} % Good looking subfigs
%% Abbreviations %% Abbreviations
\newcommand{\etal}{\textit{et al.}} \newcommand{\etal}{\textit{et al.}}
@@ -14,26 +13,25 @@
\newcommand{\vs}{\textit{vs.}\ } \newcommand{\vs}{\textit{vs.}\ }
%% Figures %% Figures
% example: \fig[1]{universe}{The Universe}[Short title for list of figures] % example: \fig[1]{universe}{The Universe}[Short title for list of figures]
% reference later with: \figref{universe} % reference later with: \figref{universe}
\NewDocumentCommand{\fig}{O{0.8} O{htbp} m m O{#4}}{% #1 = width, #2 = position, #3 = filename, #4 = caption, #5 = short caption \NewDocumentCommand{\fig}{O{0.8} O{htbp} m m O{#4}}{% #1 = width, #2 = position, #3 = filename, #4 = caption, #5 = short caption
\begin{figure}[#2] \begin{figure}[#2]
\centering% \centering%
\includegraphics[width=#1\linewidth]{#3}% \includegraphics[width=#1\linewidth]{#3}%
\caption[#5]{#4}% \caption[#5]{#4}%
\label{fig:#3}% \label{fig:#3}%
\end{figure}% \end{figure}%
} }
\NewDocumentCommand{\figwide}{O{1} O{htbp} m m O{#4}}{% #1 = width, #2 = position, #3 = filename, #4 = caption, #5 = short caption \NewDocumentCommand{\figwide}{O{1} O{htbp} m m O{#4}}{% #1 = width, #2 = position, #3 = filename, #4 = caption, #5 = short caption
\begin{figure*}[#2] \begin{figure*}[#2]
\centering% \centering%
\includegraphics[width=#1\linewidth]{#3}% \includegraphics[width=#1\linewidth]{#3}%
\caption[#5]{#4}% \caption[#5]{#4}%
\label{fig:#3}% \label{fig:#3}%
\end{figure*}% \end{figure*}%
} }
%% Sub-figures %% Sub-figures
@@ -44,65 +42,62 @@
% \end{subfigs} % \end{subfigs}
% reference later with: \figref{label} % reference later with: \figref{label}
\NewDocumentEnvironment{subfigs}{O{htbp} m m O{#3}}{% #1 = position, #2 = label, #3 = title, #4 = short title \NewDocumentEnvironment{subfigs}{O{htbp} m m O{#3}}{% #1 = position, #2 = label, #3 = title, #4 = short title
\begin{figure}[#1]% \begin{figure}[#1]%
\centering% \centering%
}{% }{%
\caption[#4]{#3}% \caption[#4]{#3}%
\label{fig:#2}% \label{fig:#2}%
\end{figure}% \end{figure}%
} }
\NewDocumentEnvironment{subfigswide}{O{htbp} m m O{#3}}{% #1 = position, #2 = label, #3 = title, #4 = short title \NewDocumentEnvironment{subfigswide}{O{htbp} m m O{#3}}{% #1 = position, #2 = label, #3 = title, #4 = short title
\begin{figure*}[#1]% \begin{figure*}[#1]%
\centering% \centering%
}{% }{%
\caption[#4]{#3}% \caption[#4]{#3}%
\label{fig:#2}% \label{fig:#2}%
\end{figure*}% \end{figure*}%
} }
\NewDocumentCommand{\subfig}{O{0.2} m o}{% #1 = width, #2 = filename, #3 = caption \NewDocumentCommand{\subfig}{O{0.2} m o}{% #1 = width, #2 = filename, #3 = caption
\IfValueTF{#3}{% \IfValueTF{#3}{%
\subfloat[#3\label{fig:#2}]{\includegraphics[width=#1\linewidth]{#2}}% \subfloat[#3\label{fig:#2}]{\includegraphics[width=#1\linewidth]{#2}}%
}{% }{%
\subfloat{\includegraphics[width=#1\linewidth]{#2}}% \subfloat{\includegraphics[width=#1\linewidth]{#2}}%
}% }%
\hfill% \hfill%
} }
\newcommand{\topleftsubcaption}{% \newcommand{\topleftsubcaption}{%
\captionsetup[subfigure]{ \captionsetup[subfigure]{
position=top, position=top,
justification=raggedright, justification=raggedright,
singlelinecheck=off, % do not center single line captions singlelinecheck=off, % do not center single line captions
labelfont={scriptsize,sf,md,up}, % smallest size, sans-serif, bold, upright labelfont={scriptsize,sf,md,up}, % smallest size, sans-serif, bold, upright
%labelformat=simple, % do not add parentheses %labelformat=simple, % do not add parentheses
farskip=0pt, % no space between caption and figure farskip=0pt, % no space between caption and figure
captionskip=0pt, % no space between caption and subfigure captionskip=0pt, % no space between caption and subfigure
margin=3pt % align caption with subfigure margin=3pt % align caption with subfigure
}% }%
} }
\newcommand{\hidesubcaption}{% \newcommand{\hidesubcaption}{%
\captionsetup[subfigure]{ \captionsetup[subfigure]{
position=top, position=top,
justification=raggedright, justification=raggedright,
labelfont={scriptsize}, % smallest size labelfont={scriptsize}, % smallest size
farskip=0pt, % no space between caption and figure farskip=0pt, % no space between caption and figure
captionskip=-10pt, % no space between caption and subfigure captionskip=-10pt, % no space between caption and subfigure
margin=4pt % align caption with subfigure margin=4pt % align caption with subfigure
}% }%
} }
%% Footnotes %% Footnotes
\newcommand{\footnoteurl}[1]{\footnote{\ \url{#1}}} \newcommand{\footnoteurl}[1]{\footnote{\ \url{#1}}}
%% Lists %% Lists
\renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\textit{#1}} % Use italics instead of bold for descriptions \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\textit{#1}} % Use italics instead of bold for descriptions
%% Maths %% Maths
\newcommand{\measure}[3]{$\mathrm{#1} = \qty{#2}{#3}$} \newcommand{\measure}[3]{$\mathrm{#1} = \qty{#2}{#3}$}
@@ -145,17 +140,16 @@
% From https://tex.stackexchange.com/a/95842 % From https://tex.stackexchange.com/a/95842
\newenvironment{conditions}{% \newenvironment{conditions}{%
\par% maybe you want the list to start with a new line \par% maybe you want the list to start with a new line
\vspace{\abovedisplayskip}% some space before \vspace{\abovedisplayskip}% some space before
\noindent% don't indent \noindent% don't indent
\tabularx{\linewidth}{>{$}l<{$} @{${}={}$} X@{}}% three columns left-aligned; first one is math-mode, the middle is an equals sign, and the last one is normal \tabularx{\linewidth}{>{$}l<{$} @{${}={}$} X@{}}% three columns left-aligned; first one is math-mode, the middle is an equals sign, and the last one is normal
}{% }{%
\endtabularx% \endtabularx%
\par% maybe you want the list to end with a new line \par% maybe you want the list to end with a new line
\vspace{\belowdisplayskip}% some space after \vspace{\belowdisplayskip}% some space after
} }
%% References %% References
\renewcommand{\eqref}[1]{Eq.~\ref{eq:#1}} \renewcommand{\eqref}[1]{Eq.~\ref{eq:#1}}
\newcommand{\figref}[1]{Fig.~\ref{fig:#1}} \newcommand{\figref}[1]{Fig.~\ref{fig:#1}}
@@ -163,7 +157,6 @@
\newcommand{\tabref}[1]{Table~\ref{tab:#1}} \newcommand{\tabref}[1]{Table~\ref{tab:#1}}
\newcommand{\footnotemarkrepeat}{\footnotemark[\value{footnote}]} % Repeat the last footnote mark \newcommand{\footnotemarkrepeat}{\footnotemark[\value{footnote}]} % Repeat the last footnote mark
%% Structure %% Structure
\newcommand{\chapterstartoc}[1]{\chapter*{#1}\addcontentsline{toc}{chapter}{#1}} \newcommand{\chapterstartoc}[1]{\chapter*{#1}\addcontentsline{toc}{chapter}{#1}}
\newcommand{\chapterstarbookmark}[1]{\pdfbookmark[chapter]{#1}{#1}\chapter*{#1}} \newcommand{\chapterstarbookmark}[1]{\pdfbookmark[chapter]{#1}{#1}\chapter*{#1}}
@@ -176,7 +169,6 @@
\newcommand{\subsubsubsection}[1]{\paragraph*{\textit{#1}}} \newcommand{\subsubsubsection}[1]{\paragraph*{\textit{#1}}}
%% Tables %% Tables
% example: % example:
% \begin{tab}{label}{Title} % \begin{tab}{label}{Title}
@@ -187,26 +179,25 @@
% \end{tab} % \end{tab}
% reference later with: \tabref{label} % reference later with: \tabref{label}
\NewDocumentEnvironment{tab}{O{htbp} m m}{% #1 = position, #2 = label, #3 = title \NewDocumentEnvironment{tab}{O{htbp} m m}{% #1 = position, #2 = label, #3 = title
\begin{table}[#1]% \begin{table}[#1]%
\centering% \centering%
\caption{#3}% \caption{#3}%
\label{tab:#2}% \label{tab:#2}%
}{% }{%
\end{table}% \end{table}%
} }
\NewDocumentEnvironment{tabwide}{O{htbp} m m}{% #1 = position, #2 = label, #3 = title \NewDocumentEnvironment{tabwide}{O{htbp} m m}{% #1 = position, #2 = label, #3 = title
\begin{table*}[#1]% \begin{table*}[#1]%
\centering% \centering%
\caption{#3}% \caption{#3}%
\label{tab:#2}% \label{tab:#2}%
}{% }{%
\end{table*}% \end{table*}%
} }
\newcommand{\tabrow}[1]{#1 \\ \hline} \newcommand{\tabrow}[1]{#1 \\ \hline}
%% Other %% Other
\newcommand{\horizontalrule}{\par\noindent\rule{\textwidth}{0.4pt}} % Horizontal line \newcommand{\horizontalrule}{\par\noindent\rule{\textwidth}{0.4pt}} % Horizontal line
@@ -214,7 +205,6 @@
\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1} % Convert units. Usage: \convertto{cm}{1pt}. From: https://tex.stackexchange.com/a/8337 \def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1} % Convert units. Usage: \convertto{cm}{1pt}. From: https://tex.stackexchange.com/a/8337
\makeatother \makeatother
%% User studies %% User studies
\newcommand{\factor}[1]{\textsc{#1}} \newcommand{\factor}[1]{\textsc{#1}}
\newcommand{\level}[1]{\textsl{#1}} \newcommand{\level}[1]{\textsl{#1}}