2

For a book, I want to change the default font in the Examples environment (declared in the same way as theorem) to the usual roman (not italic) so that there are not very large areas of italic font. How do I do this without causing complications elsewhere? Can it be done in one declaration or must it be done separately in every case?

1
  • A minimal compilable example would be welcome. So we have a starting point, which eases the work of whoever wants to help you.
    – Manuel
    Jul 29, 2014 at 10:31

2 Answers 2

3

If you are using theorem-like environments, with

\usepackage{amsthm}

then you can define them as remark-style or definition-style, like :

\theoremstyle{remark}
\newtheorem{ex}{Example}

As explained in the "Theorem styles" section here.

3
  • 1
    The question was about fonts in general in a theorem environment, switching to another style without giving a clue how to change the style's definition or adding a new style does not provide much help
    – user31729
    Jul 29, 2014 at 10:47
  • @ChristianHupfer The question seems to be about changing italic font to roman one in a specific case, specifically asking for simplicity. Jul 29, 2014 at 11:35
  • I use a document class (llncs template) that has already a definition for proof and when I use the amsthm package I get an error about that. Is there another way to change the style of a new theorem environment?
    – Lpax
    Dec 12, 2023 at 15:24
1

Finally after reading through several posts and resources online I've been able to get my head around how an example environment could be defined with different font and proper indentation as well.

Below I present the code. To keep it readable I've provided comment for each argument, parameter which has bloated the code but my aim is to keep it readable and understandable

 %in the preamble

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[T1]{fontenc}

%%%%%  environment definition begins %%%%%
\newcounter{example}[chapter] %counter for example
\newenvironment{example}      %name of environment
 [1]                          %number of arguments for the environment
 [Default value of  argument if none provided]
{\refstepcounter{example}     %be able to label 
 \par                         %starts the example in a new paragraph
\textbf{Example~\thechapter.\theexample } %how the example should like, 
                                          %bold here, Example 2.3
\textit{#1}                   %additional argument will be italisized

                              %all the codes here onwards specify the
                              % properties of the body of example

\fontfamily{pcr} \selectfont  %font for body of example
\leftskip=1em  \rightskip=2em %indentation for the body
\par                          %the body of example starts in a new paragraph
}
{\par                  %new paragraph when the body of example ends
\vspace{\baselineskip} %additional vertical spacing to 
                       %show that example has ended   
\noindent              %stop anymore indentation 
 }

%%%%%  environment definition ends %%%%

Somewhere In second chapter where 4th example is being documented

\begin{document}
%somewhere in the document 
\begin{example}[This is an example]
The body of the example is here but this appears no different than the body of the section that follows. I need either different font or a different indentation to make it look like an example \\

this is a  part of example %need to insert newline to break line
\end{example}
\textbf{this is not a part of example and now finally distinguishable }

\end {document}

The result looks like this :

enter image description here

The argument passed to the example is in italics, the body of the example, indented accordingly, is using different font and at the end of example the indentation stops and the section/subsection within which the example is written continues as it should.

Hope this helps.

You must log in to answer this question.

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