0

Is there a standard formatted environment specifically used for examples? I'm writing a document on linear algebra, with the usual definition-theorem-proposition-example structure. Right now when I insert an example, I get something like:enter image description here

This is a screenshot I took. Here is the MWE:

\documentclass[11pt,a4paper,openany]{report}
\usepackage{amssymb,amsmath,mathrsfs}
\usepackage[dutch]{babel}
\usepackage{lmodern}
\usepackage{mdframed}
\usepackage{bm}
\usepackage[many]{tcolorbox}
\usepackage{systeme,mathtools}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
   \hskip -\arraycolsep
   \let\@ifnextchar\new@ifnextchar
   \array{#1}}
\makeatother
\usepackage{lipsum}
\usepackage{relsize}
\let\conjugatet\overline
\DeclareMathOperator{\Ima}{Im}
\DeclareMathOperator{\Span}{span}
\newcommand\md{\ }
\renewcommand{\qedsymbol}{$\blacksquare$}
\pagestyle{plain}
\renewcommand\baselinestretch{1.0}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.5}
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}
\theoremstyle{definition}
\newmdtheoremenv[linewidth=1.0pt,linecolor=red]{Definition}{Definitie}
\numberwithin{Definition}{section}
\newmdtheoremenv[linewidth=1.0pt,linecolor=black]{Theorem}{Theorema}
\numberwithin{Theorem}{section}
\newtheorem{lemma}{Lemma}
\numberwithin{lemma}{section}
\newtheorem{proposition}{Propositie}
\numberwithin{proposition}{section}
\newtheorem{corollary}{Corollarium}
\numberwithin{corollary}{section}
\newtheorem{exmp}{Voorbeeld}[section]
\newcommand{\prooffont}{\scshape}
\usepackage{xpatch}
\tracingpatches
\xpatchcmd{\proof}{\itshape}{\prooffont}{}{}

\usepackage{marvosym}    %Here starts the part you said I should add.
\usepackage{etoolbox}
\usepackage[amsmath, thref, hyperref, thmmarks]{ntheorem}
\theorembodyfont{\upshape}
\theoremseparator{.}
\theoremsymbol{\Large\color{Plum4}\Bat}
\newtheorem{exmp}{Voorbeeld}[section]
\AtBeginEnvironment{exmp}{\AtBeginEnvironment{itemize}{\leavevmode}      \AtBeginEnvironment{enumerate}{\leavevmode}}

The 'Voorbeeld' is Dutch for 'example'. The problem I'm having is that I want my text directly aligned underneath the 'example' caption. In this case I used the 'itemize' command, but I want it to apply for all cases. This is what I wish to change:

Example 4.2.1. (---text comes here----)

I want the text under the 'example' caption, and also have it closed by some symbol (something other than the tombstone for proofs) at the end so that the reader knows the example ends here. Is there any way I could get this done?

Here another screenshot:enter image description here

As can be seen, my text immediatly starts after the caption, which is not what I want.

Thanks in advance for any help.

Edit: Here is what I mean with a possible reduction of quality-output. I entered as code:

\begin{equation} \label{2} [v]_{\gamma} = (b_1, b_2, \ldots, b_n)^T. \end{equation}

But this is what I received:

enter image description here

Notice the gamma float without being attached to my coordinate vector.

2
  • Please provide an MWE of this screenshot. Delete all packages which are not needed here in order to make it easier for us. Do you want the described behaviour just for enumerations? Your Example 4.2.1. looks like the normal result. Please clarify this a bit!
    – LaRiFaRi
    Apr 14, 2015 at 11:35
  • I don't want the text right next to the 'example' caption. I want the text to start one line beneath the caption.
    – Kamil
    Apr 14, 2015 at 13:13

1 Answer 1

1

You can do that easily with the ntheorem package (instead of amsthm) and etoolbox. I also loaded the enumitem package to improve the layout of itemize environments in such context. Here is a possible code:

\documentclass[11pt,a4paper,openany]{report}
\usepackage[utf8]{inputenc}
\usepackage{amssymb, mathrsfs}
\usepackage[dutch]{babel}
\usepackage{lmodern}
\usepackage{mdframed}
\usepackage{bm}
\usepackage[many]{tcolorbox}
\usepackage{systeme, mathtools}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother
\usepackage{lipsum}
\usepackage{relsize}
\let\conjugatet\overline
\DeclareMathOperator{\Ima}{Im}
\DeclareMathOperator{\Span}{span}
\newcommand\md{\ }
%\renewcommand{\qedsymbol}{$\blacksquare$}
\pagestyle{plain}
\renewcommand\baselinestretch{1.0}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.5}
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}
\usepackage[amsmath, thref, hyperref, thmmarks]{ntheorem}
\renewcommand{\qedsymbol}{blacksquare}
\theoremstyle{definition}
\theoremseparator{.}
\newmdtheoremenv[linewidth=1.0pt,linecolor=red]{Definition}{Definitie}[section]
\newmdtheoremenv[linewidth=1.0pt,linecolor=black]{Theorem}{Theorema}[section]
\theoremheaderfont{\bfseries\upshape}
\theorembodyfont{\itshape}
\newtheorem{lemma}{Lemma}[section]
\newtheorem{proposition}{Propositie}[section]
\newtheorem{corollary}{Corollarium}[section]
\theoremstyle{break}
\theorembodyfont{\upshape}
\theoremsymbol{\ensuremath{\clubsuit}}
\newtheorem{exmp}{Voorbeeld}[section]

\theoremstyle{nonumberplain}
\theoremheaderfont{\scshape}
\theoremsymbol{\ensuremath{\blacksquare}}
\newtheorem{proof}{Bewijs}

\usepackage{enumitem} 
\usepackage{etoolbox}
\AtBeginEnvironment{exmp}{\setlist[itemize, 1]{wide=0em, leftmargin=1.25em, labelwidth=0.7em}}

\begin{document}
\setcounter{chapter}{1}
\setcounter{section}{1}
\setcounter{exmp}{1}


\begin{exmp}
  \begin{itemize}
    \item $ (\mathbb R,\mathbb C, + )$ is een reële (en dus geen complexe) vectorruimte. Nemen wij immers een willekeurige scalar $ λ ∈ \mathbb R$ en vermenigvuldigen we een willekeurige vector $ (a + bi) ∈ \mathbb C$ met deze scalar, dan behoort het product $ (λ a + λ bi) $ tot $ \mathbb C$. In dit geval hebben wij dus $ \mathbb R × \mathbb C\to \mathbb C~~\colon (λ,a + bi) ↦ (λ a + λ bi)$.
    \item $ (\mathbb C, \mathbb R, +) $ is geen complexe vectorruimte, $ (\mathbb C, \mathbb C, + ) $ echter wel.
  \begin{equation*} \label{2}{} [v]_{\gamma} =(b_1, b_2, \ldots, b_n)^T.\end{equation*}
  \end{itemize}
\end{exmp}

\begin{Definition}
  A fully understandable definition.
\end{Definition}
\begin{lemma}
  A test lemma.
\end{lemma}

\begin{proof}
  A proof for fun!

  End of proof:
\begin{align*}
    a & =b\\
    a + c & =b + d
\end{align*}
\end{proof}


\end{document} 

enter image description here

9
  • Tried adding it to my document, but it then builds forever when I click the 'build' button. I deleted the line \usepackage[amsmath, thref, hyperref, thmmarks]{ntheorem} and then it stopped building and gave me 6 errors. But when I add this line it doesn't work.
    – Kamil
    Apr 14, 2015 at 14:13
  • It says: "Package ntheorem error: Theorem style plain already defined."
    – Kamil
    Apr 14, 2015 at 14:14
  • 1
    Don't load both amsthm and ntheorem. If you like the amsthm formatting, the amsthm option of ntheorem provides an emulation.
    – Bernard
    Apr 14, 2015 at 14:22
  • Still doesn't work, now it says: \qedsymbol undefined. Maybe I should add a full MWE? I have several other environments and maybe they don't go together.
    – Kamil
    Apr 14, 2015 at 14:24
  • Yes, that would make it easier to find what's happening. Can you compile my code?
    – Bernard
    Apr 14, 2015 at 14:28

You must log in to answer this question.

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