2

I am using mdframed, and I would like the theorem number to have the same font as the theorem name, like it is shown here:

enter image description here

Also, the theorem number should finish with a period: "Example 1.1.", "Example 1.2."

Here is my 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 Answer 1

2

I solved my own question:

enter image description here

with the following code:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .