使用 mdframed 的定理数字字体和最后句点

使用 mdframed 的定理数字字体和最后句点

我正在使用mdframed,并且我希望定理编号具有与定理名称相同的字体,如下所示:

在此处输入图片描述

此外,定理编号应该以句点结尾:“示例 1.1。”,“示例 1.2。”

这是我的 MWE:

\documentclass{article}

\usepackage{roboto}
\usepackage{fourier}

\usepackage{amsthm, amsmath}

\usepackage[usenames,dvipsnames,table]{xcolor} 
\definecolor{blue-header}{RGB}{130,160,200}

\usepackage[framemethod=latex]{mdframed}

\theoremstyle{ejemplo}
\mdfdefinestyle{estiloejemplo}{%
    topline=false,
    leftline=true,
    bottomline=false,
    rightline=false,
    linewidth = 4pt, %
    linecolor = blue-header,
    frametitleaboveskip = 0,  % distancia del teorema a la parte superior 
    innerrightmargin = 0,     % margen derecha
    frametitlefont = \normalfont,
    innerbottommargin = 0,    % distancia del teorema a la parte inferior
    theoremtitlefont = \itshape,
} 

\mdtheorem[style=estiloejemplo]{ejemplo}{\textbf{\textsf{\textcolor{blue-header}{Example}}}}[section]

\begin{document}
    \section{A section}
    Some text.
    
    \begin{ejemplo}[This is the title of the exercise, which spans several lines and should be in italic font. This is the title of the exercise, which spans several lines and should be in italic font]
    where $m$ is the slope, and $b$ is the intersect.     where $m$ is the slope, and $b$ is the intersect. 
    \end{ejemplo}

    Some other test

    \begin{ejemplo}
        This is another example
    \end{ejemplo}      

The final text
\end{document} 

答案1

我解决了我自己的问题:

在此处输入图片描述

使用以下代码:

\documentclass{article}

%fonts
\usepackage{roboto}
\usepackage{fourier}

\usepackage{amsthm, amsmath}

\usepackage[usenames,dvipsnames,table]{xcolor} 
\definecolor{blue-header}{RGB}{130,160,200}

\usepackage[framemethod=latex]{mdframed}
    
\newcounter{ejemplo}[section]
\newenvironment{ejemplo}[1][]{%
    \refstepcounter{ejemplo}%
    \ifstrempty{#1}%
    {%
        \mdfsetup{frametitle={\textbf{\textsf{\textcolor{blue-header}{Example~\theejemplo.}}}}}
    }%
    {%
        \mdfsetup{frametitle={\textbf{\textsf{\textcolor{blue-header}{Example~\theejemplo.}}}~\textit{#1}}}
    }%
    \mdfsetup{%
        topline=false,
        leftline=true,
        bottomline=false,
        rightline=false,
        linewidth = 4pt, %
        linecolor = blue-header,
        %    skipabove = 40,          % distancia superior
        %    skipbelow = 40,          % distancia inferior
        frametitleaboveskip = 0,  % distancia del teorema a la parte superior 
        innerrightmargin = 0,     % margen derecha
        frametitlefont = \normalfont,
        innerbottommargin = 0,    % distancia del teorema a la parte inferior
        theoremtitlefont = \itshape,
    } 
    \begin{mdframed}[]\relax%
    }{\end{mdframed}}
    
\renewcommand{\theejemplo}{\thesection.\arabic{ejemplo}}% ...for chapter prefix
    
    
\begin{document}    
    \section{A section}
Some text.

\begin{ejemplo}[This is the title of the exercise, which spans several lines and should be in italic font. This is the title of the exercise, which spans several lines and should be in italic font]
    
    %    Here it is not indented. This is the postulate of the example. This is the postulate of the example. This is the postulate of the example. This is the postulate of the example. This is the postulate of the example.
    %    
    %    Here it is indented. This is the postulate of the example. This is the postulate of the example. This is the postulate of the example.
    %    \begin{enumerate}
        %       \item This is the first thing that we have to do. This is the first thing that we have to do. This is the first thing that we have to do.
        %       \item This is the second thing that we have to do. This is the second thing that we have to do. This is the second thing that we have to do.
        %    \end{enumerate}
    %    And there is and equation:
    %    \begin{align}
        %        f(x) &= mx+b &
        %        I &= \int_a^b f(x) \mathrm{d}\!x
        %    \end{align}
    where $m$ is the slope, and $b$ is the intersect.     where $m$ is the slope, and $b$ is the intersect. 
\end{ejemplo}

Some other test

\begin{ejemplo}
    This is another example
\end{ejemplo}      

The final text
\end{document}

相关内容