captions – How to reset \captionsetup{} to default after changing it before in the document – TeX


I have already successfully changed the \captionsetup{} of my document to a different format provided in the code below. However, I need to come back to the original \captionsetup{} but it does not clear the previous specification and come back to default. I need help with this. Below is a minimal working example (MWE) that should be working on Overleaf, but it doesn’t.

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{caption}
\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}

\begin{figure}
  \centering
  \caption{A default caption.}
  \label{fig:default}
\end{figure}

% Change the caption setup
\captionsetup{labelfont=bf, textfont=it}

\begin{figure}
  \centering
  \caption{A custom caption.}
  \label{fig:custom}
\end{figure}

% Clear the caption setup
\captionsetup{}

\begin{figure}
  \centering
  \caption{Back to default caption.}   % This caption stays the same as the previous one
  \label{fig:backToDefault}   
\end{figure}

\end{document}

I am using XeLaTeX to compile the project taking into account the need of it to use Arial as main text font.



Source link

Leave a Comment