Text Formattingntheorem | Remove Indentation with Theorem Style "margin"

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
voorneveld
Posts: 15
Joined: Mon Sep 07, 2009 11:18 am

ntheorem | Remove Indentation with Theorem Style "margin"

Post by voorneveld »

In the MWE below, I define an example environment with numbers in the margin. Its first line, however, is indented, rather than starting at the left margin. How to avoid this indentation? My guess \noindent does not work.

Code: Select all

\documentclass{article}

\usepackage{ntheorem}
\theoremstyle{margin}
\theoremheaderfont{\small\bfseries}
\theorembodyfont{\small}
\theoremsymbol{}
\newtheorem{exercise}{}[section]

\begin{document}
\setcounter{section}{1}
\begin{exercise}
\noindent First line.

\noindent Second line.
\end{exercise}
\end{document}
Last edited by Stefan Kottwitz on Tue Apr 10, 2012 3:24 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

ntheorem | Remove Indentation with Theorem Style "margin"

Post by localghost »

The cause seems to be that in every case there is some space reserved between the name of the theorem and the beginning text. Since you don't give a name to your exercise theorem environment, you have to correct this. Instead of the name just add some negative horizontal space.

Code: Select all

\newtheorem{exercise}{\hspace*{-0.45em}}[section]
The horizontal space is deliberately chosen in a unit that depends on the font size.


Thorsten
voorneveld
Posts: 15
Joined: Mon Sep 07, 2009 11:18 am

Re: ntheorem | Remove Indentation with Theorem Style "margin

Post by voorneveld »

Thank you so much!

Mark
Post Reply