6

How can I get universal in my new environment normalfont instead of italic (default)? I thought it was something simple like

\newtheorem{exercise}{ \normalfont}[chapter] `

but doesn't work. I could not find something similar but I think it is something simple, even for me as a new user to LaTeX.

lockstep
  • 250,273
karathan
  • 2,138
  • 2
  • 17
  • 32

3 Answers3

11

For instance (using amsthm) this.

\documentclass{book}

\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{example}{Example}[chapter]

\begin{document}

\chapter{Hello world}
\begin{example}
  I am an example of proper usage of the \texttt{amsthm} package.
\end{example}

\end{document}

See also the documentation for amsthm for defining your own theorem styles, and also other theorem-generating packages (ntheorem being probably the most widely used).

mbork
  • 13,385
  • Thanks @mbork this worked well. But if I have more than one \newtheorem{example1}{Example1}[chapter]and \newtheorem{example2}{Example2}[chapter] and I just want some of them are normal fonts and some defaultthen how can I do it? – karathan Dec 08 '11 at 10:45
  • 7
    divide your \newtheorem declarations by style, and put an appropriate \theoremstyle command before each group. the current \theoremstyle stays in effect until overridden by a different one. – barbara beeton Dec 08 '11 at 14:10
  • 1
    I just tried and indeed it works exactly as I like – karathan Dec 08 '11 at 21:23
6

I prefer the key--value syntax of the thmtools package (which may use amsthm or ntheorem as backend).

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[headfont=\normalfont]{normalhead}
\declaretheorem[style=normalhead]{example}

\begin{document}

\begin{example}
Some text.
\end{example}

\end{document}

enter image description here

lockstep
  • 250,273
3

Here's an example using ntheorem. Note that each declaration of

\newtheorem{...}

inherits the current theoremstyle and associated settings.

In the example below, both mytheorem and anothertheorem have exactly the same style. If you were to put some different settings, perhaps changing the \theorembodyfont{} for example, immediately before

\newtheorem{anothertheorem}{Another Theorem}

then anothertheorem would inherit these new settings. See the ntheorem documentation for more details.

MWE

\documentclass{article}

\usepackage{ntheorem}   % for theorems
\usepackage{lipsum}     % for sample text

\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theorembodyfont{}      % try commenting this line
\theoremprework{}       % code to process before the theorem 
\theorempostwork{}      % code to process after the theorem 
\theoremseparator{:}    % could be a : for example

% first theorem
\newtheorem{mytheorem}{My Theorem}

% another theorem
\newtheorem{anothertheorem}{Another Theorem}

\begin{document}

\begin{mytheorem}
 \lipsum[1]
\end{mytheorem}

\begin{anothertheorem}
\lipsum[2] 
\end{anothertheorem}

\end{document}
cmhughes
  • 100,947