1

I did not find bold word in the manual. My tex is:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\newtheorem{question}{Question}
\mdfdefinestyle{que}{
  linecolor=cyan,
  backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}
\begin{document}
\begin{question}
Lorem. % No bolding needed here so save space here, but need to fix the above
\end{question}
\end{document}

How can you have bold font in mdframed environment?

pluton
  • 16,421

1 Answers1

6

If I understand your question correctly, you want to have a kind of title for your questions and that title should be bold-faced, In this case, you can define a new theorem style and use the note field (the optional argument) to get the desired result:

\documentclass{article}
\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}

\newtheoremstyle{mystyle}
  {\topsep}%
  {\topsep}%
  {\itshape}%
  {}%
  {\bfseries}%
  {.}%
  {.5em}%
  {\thmname{#1}~\thmnumber{#2}\thmnote{. \bfseries#3}}%
\theoremstyle{mystyle}
\newtheorem{question}{Question}
\mdfdefinestyle{que}{
  linecolor=cyan,
  backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}
\begin{document}
\begin{question}[Lorem]
Text
\end{question}
\begin{question}
Text
\end{question}
\end{document}

enter image description here

If, on the other side you want all the contents bold-faced, you have two options:

  1. If you are not using amsthm, simply add font=\bfseries to the mdframed specifications:

    \documentclass{article}
    \usepackage[framemethod=tikz]{mdframed}
    
    \newtheorem{question}{Question}
    \mdfdefinestyle{que}{
      linecolor=cyan,
      font=\bfseries,
      backgroundcolor=cyan!20,
    }
    \surroundwithmdframed[style=que]{question}
    \begin{document}
    \begin{question}
    Text
    \end{question}
    \end{document}
    
  2. If you are using amsthm, you'll need to add the specification to the theorem style:

    \documentclass{article}
    \usepackage{amsthm}
    \usepackage[framemethod=tikz]{mdframed}
    
    \newtheoremstyle{mystyle}
      {\topsep}%
      {\topsep}%
      {\bfseries\itshape}%
      {}%
      {\bfseries}%
      {.}%
      {.5em}%
      {}%
    \theoremstyle{mystyle}
    \newtheorem{question}{Question}
    \mdfdefinestyle{que}{
      linecolor=cyan,
      backgroundcolor=cyan!20,
    }
    \surroundwithmdframed[style=que]{question}
    \begin{document}
    \begin{question}
    Text
    \end{question}
    \end{document}
    

enter image description here

Notice that italics plus bold-face might not be the best choice.

Gonzalo Medina
  • 505,128