具有恒定编号但适应 mdframed 环境风格的标题

具有恒定编号但适应 mdframed 环境风格的标题

在我的文档中,我重新定义了命令\thefigure以根据需要自定义标题。我还使用了四种不同的 mdframed 环境:一种用于证明,一种用于示例,一种用于命题,一种用于定义。事实证明,我使用这些环境不仅定义特定类型的框架和背景颜色;还定义这些框架内的字体。因此,证明采用脚注大小;而示例采用小斜体字体(定义和命题具有标准傅立叶字体)。

问题如下。我的文档有几个图,其中一些属于这些不同的 mdframed 环境。当在这些 mdframed 环境中包含图时,标题样式显然保持正常。也就是说,如果在证明环境中有一个图,则标题将不会采用脚注大小(类似地;如果在示例中,图的标题将不会采用小斜体字体)。正如您所猜测的,我希望我的标题能够获得它们所在的相应 mdframed 环境的字体样式。也就是说,我希望证明环境中的标题采用脚注大小,示例环境中的标题采用斜体和小字体。但是,我不希望更改标题的编号。也就是说:标题样式应适应相应的 mdframed 环境字体样式;但标题的编号不应改变。这是一个 MWE,展示了我如何定义 mdframed 环境以及标题。为了通用性,MWE 并没有达到应有的最小化;但我认为这样更好。

\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}

下面您可以看到一个证明,其中的标题样式并未进行相应的调整。

在此处输入图片描述

有人能帮我实现所需的输出吗?也就是说,我应该怎么做才能获得固定编号但又适合标题的样式?谢谢大家的时间。:)

答案1

按照 crf 注释,以下代码生成所需的输出:

\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}

与原始代码相比,唯一的区别在于包含了\captionsetup{font=footnotesize}\newtheoremstyle{mystyle0}...输出如下所示。

在此处输入图片描述

相关内容