0

In my document, I have re-defined the command \thefigure to customise captions as desired. I am also working with four different mdframed environments: one for proofs, one for examples, one for propositions and one for definitions. It turns out that I use these environments to define not only particular types of frames and background colors; but also the font inside of those frames. Hence, proofs are in footnotesize; whereas examples are in small and italic font (definitions and propositions have standard Fourier font).

The issue is as follows. My document has several figures, some of which fall into these different mdframed environments. When including figures in those mdframed environments, caption style is obviously kept normal. That is, if there is a figure inside a proof environment, the caption will NOT be in footnotesize (analogously; if inside an example, the caption of the figure will NOT be in small and italic font). As you can guess, I'd like my captions to get the style of the font of the corresponding mdframed environment they are in. That is, I'd like captions inside the proof environment to be in footnotesize and captions inside an example environment to be in italics and small font. However, I do NOT want the numeration of the captions to be changed. That is: caption style should adapt to the corresponding mdframed environment font style; but the numbering of the captions should not be altered. Here is a MWE that shows how I am defining the mdframed environments, as well as captions. For the sake of generality, the MWE is not as minimal as it should; but I think it is better this way.

\documentclass{report}

% PACKAGES LOADING

\usepackage[sloped]{fourier} % To customise font.
\usepackage{setspace} % To format text line spacing.
\usepackage[dvipsnames]{xcolor} % To get many colours.
\usepackage{amsmath, mathtools, amsthm, mathrsfs, amssymb} % MATH Packages
\usepackage[labelfont=bf,skip=0pt,labelsep=space,justification=centering]{caption} % To customise captions.
\usepackage[]{mdframed} % To get page-breakable proofs.

% DEFINING CUSTOM ENVIRONMENTS

\makeatletter

\newtheoremstyle{mystyle0}{0}{}{}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle0}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,linecolor=Blue,linewidth=0.5mm,hidealllines=false,nobreak=true]{proposition}{Proposition}[section]

\newtheoremstyle{mystyle2}{0}{}{}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle2}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=false,backgroundcolor=White!10,nobreak=true,linewidth=0.5mm,linecolor=Gray!70]{definition}{Definition}[section]

\newtheoremstyle{mystyle3}{0}{}{\itshape}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle3}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,linewidth=2pt,backgroundcolor=Gray!10,nobreak=false,hidealllines=true,roundcorner=10pt]{example}{Example}
\renewcommand{\theexample}{\relax}

\makeatother

\newtheoremstyle{mystyle1}{0}{}{\footnotesize\setstretch{1.35}}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle1}
\let\proof\relax
\let\endproof\relax
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=true,backgroundcolor=Blue!7.5,nobreak=false,roundcorner=10pt]{proof}{Proof}[section]
\renewcommand{\theproof}{\relax}
\AtEndEnvironment{proof}{\null\hfill$\blacksquare$}

% NUMBERING DEFINITION

\makeatletter

\numberwithin{proposition}{section}
\numberwithin{proof}{section}
\numberwithin{definition}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}.\Roman{figure}}
\captionsetup[figure]{labelsep=period}

\renewcommand{\thedefinition}{\arabic{chapter}.\arabic{section}.\Alph{definition}}
\renewcommand{\theproposition}{\arabic{chapter}.\arabic{section}.\arabic{proposition}}

\makeatother

\begin{document}

\begin{proof}[\textbf{Random Proof}]

Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? [33] At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

\begin{center}
\begin{tabular}{ccccc} 
\hline
     & \textbf{f} & \textbf{g} & \textbf{F} & \textbf{G} \\\hline
    $x_5$ & 0.2 & 0.1 & 1.0 & 1.0 \\ 
    $x_4$ & 0.0 & 0.1 & 0.8 & 0.9 \\ 
    $x_3$ & 0.4 & 0.3 & 0.8 & 0.8 \\ 
    $x_2$ & 0.3 & 0.4 & 0.4 & 0.5 \\ 
    $x_1$ & 0.1 & 0.1 & 0.1 & 0.1 \\ \hline
\end{tabular}
\medbreak
\captionof{figure}{Random Table}
\end{center}

And happy \LaTeX-ing!

\end{proof}

\end{document}

Below you can see a proof in which the style of the caption is not adapted accordingly.

enter image description here

Could anyone help me achieve the desired output? That is, what should I do to get constant numbering but adapted style for my captions? Thank you all for your time. :)

2
  • 1
    Use the \captionsetup within the environment definitions? Why are you classifying a table as a figure? – cfr Mar 26 '17 at 22:35
  • Great! I included it in the definition of the environment and it works. I'll answer this question soon with the proposed working solution. – Héctor Mar 27 '17 at 10:39
0

Following crf comment, the following code generates the desired output:

\documentclass{report}

% PACKAGES LOADING

\usepackage[sloped]{fourier} % To customise font.
\usepackage{setspace} % To format text line spacing.
\usepackage[dvipsnames]{xcolor} % To get many colours.
\usepackage{amsmath, mathtools, amsthm, mathrsfs, amssymb} % MATH Packages
\usepackage[labelfont=bf,skip=0pt,labelsep=space,justification=centering]{caption} % To customise captions.
\usepackage[]{mdframed} % To get page-breakable proofs.

% DEFINING CUSTOM ENVIRONMENTS

\makeatletter

\newtheoremstyle{mystyle0}{0}{}{}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle0}
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,linecolor=Blue,linewidth=0.5mm,hidealllines=false,nobreak=true]{proposition}{Proposition}[section]

\newtheoremstyle{mystyle2}{0}{}{}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle2}
 \newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=false,backgroundcolor=White!10,nobreak=true,linewidth=0.5mm,linecolor=Gray!70]{definition}{Definition}[section]

\newtheoremstyle{mystyle3}{0}{}{\itshape}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle3}
 \newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,linewidth=2pt,backgroundcolor=Gray!10,nobreak=false,hidealllines=true,roundcorner=10pt]{example}{Example}
 \renewcommand{\theexample}{\relax}

\makeatother

\newtheoremstyle{mystyle1}{0}{}{\footnotesize\setstretch{1.35} \captionsetup{font=footnotesize}}{}{\bfseries}{\newline}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}}
\theoremstyle{mystyle1}
\let\proof\relax
\let\endproof\relax
\newmdtheoremenv[innerleftmargin=0.2cm,innerrightmargin=0.2cm,innertopmargin=0.2cm,innerbottommargin=0.2cm,hidealllines=true,backgroundcolor=Blue!7.5,nobreak=false,roundcorner=10pt,]{proof}{Proof}[section]
\renewcommand{\theproof}{\relax}
\AtEndEnvironment{proof}{\null\hfill$\blacksquare$}

% NUMBERING DEFINITION

\makeatletter

\numberwithin{proposition}{section}
\numberwithin{proof}{section}
\numberwithin{definition}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}.\Roman{figure}}
\captionsetup[figure]{labelsep=period}

\renewcommand{\thedefinition}{\arabic{chapter}.\arabic{section}.\Alph{definition}}
\renewcommand{\theproposition}{\arabic{chapter}.\arabic{section}.\arabic{proposition}}

\makeatother

\begin{document}

\begin{proof}[\textbf{Random Proof}]
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur? [33] At vero eos et accusamus et iusto odio dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati cupiditate non provident, similique sunt in culpa, qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio, cumque nihil impedit, quo minus id, quod maxime placeat, facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

\begin{center}
\begin{tabular}{ccccc} 
\hline
     & \textbf{f} & \textbf{g} & \textbf{F} & \textbf{G} \\\hline
    $x_5$ & 0.2 & 0.1 & 1.0 & 1.0 \\ 
    $x_4$ & 0.0 & 0.1 & 0.8 & 0.9 \\ 
    $x_3$ & 0.4 & 0.3 & 0.8 & 0.8 \\ 
    $x_2$ & 0.3 & 0.4 & 0.4 & 0.5 \\ 
    $x_1$ & 0.1 & 0.1 & 0.1 & 0.1 \\ \hline
\end{tabular}
\medbreak
\captionof{figure}{Random Table}
\end{center}

And happy \LaTeX-ing!

\end{proof}

\end{document}

The only difference with respect to the original code lies in the inclusion of \captionsetup{font=footnotesize} in \newtheoremstyle{mystyle0}.... The output can be seen below.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.