1

I wrote a Math report, and I wanted to indent a whole paragraph in my definition, such that it's aligned with the end of the word definition.

For a while I used minipage and it works well :

\begin{definition}
\begin{minipage}[t]{0.80\linewidth}
$\mathcal{G}$(n,M), où $ 0\leqslant M\leqslant N$, consiste en tous les $\dbinom{N}{M}$ sous-graphes de $K_n$ à M arêtes.
\end{minipage}
\end{definition}

with definition defined as :

\theoremstyle{definition}
\newtheorem{definition}{Définition}[section]

But for one paragraph it doesn't work, (in fact it works but there is an underfull warning and the space between words are bigger than usual), so my question was can I work on my definition of definiton to make all paragraphs indent like this:

Definition 2.2: blalablablabla 

                blablablablabla
4
  • 2
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Skillmon Mar 28 '18 at 15:07
  • So you did success in typesetting it with a hanging indent, but got an underfull box? Perhaps you should search for how you can solve the underfull box issues. There should be plenty questions on this site covering that. – Skillmon Mar 28 '18 at 15:08
  • I did success in typesetting but with a solution that I didn't like, since that every time I made a minipage, I had to adjust multiple times to get the right width. I want to know if there is an other way to define the indentation in the definition of definition, such that the indentation is automatic when I write in my definition. – Rhotaber Mar 28 '18 at 15:18
  • \setbox0\hbox{Definition \thedefinition:} then \begin{minipage}{\dimexpr\textwidth-\wd0}. Don't know whether \thedefinition is the correct counter, perhaps there needs to be something else. – Skillmon Mar 28 '18 at 15:46
2

I think it would probably be better to change the overall indentation inside the definition environment instead of using a minipage. Two methods for doing this are outlined in these two answers (to same question).

The only problem is that we don't know the amount by which we want to indent beforehand, since it depends on the name of the theorem. By the time amsthm gets around to creating the theorem head it is too late to obtain its width from any of the arguments of \newtheoremstyle, so I've instead added the required code to \@begintheorem:

\documentclass{article}
\usepackage{etoolbox} %% For \apptocmd
\usepackage{amsthm}

\makeatletter
\apptocmd{\@begintheorem}{%
  \advance\@totalleftmargin by \wd\@labels
  \advance\linewidth by -\wd\@labels
  \parshape 1 \@totalleftmargin \linewidth
  \sbox\@labels{\makebox[0pt][r]{\unhbox\@labels}}%
  \ignorespaces %% Because the original ended with this
}{}{}
\makeatother

\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\begin{document}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.

\begin{definition}
    Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

    Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. 
\end{definition}

Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Cur- abitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.

\end{document}

Here is the result:

enter image description here

A little explanation: amsthm stores the theorem head in a box called \@labels and it inserts this at the start of the first paragraph of the theorem. I just added the width of this box to the left margin and subtracted it from the line width and I then changed the box itself so that it takes up no horizontal space and sticks out on the left. You can do this manually at the start of the environment, but I'm using etoolbox to append these instructions to \@begintheorem.


Note: this affect all theorem environments, not just definitions. Some further modification is required if this is undesirable. The following alternative allows you to add \indentbyhead to the fourth argument of \newtheoremstyle (body font) to (only) indent theorems defined using this style.

\newif\ifindentbyhead
\let\indentbyhead\indentbyheadtrue
\makeatletter
\apptocmd{\@begintheorem}{%
  \ifindentbyhead
    \advance\@totalleftmargin by \wd\@labels
    \advance\linewidth by -\wd\@labels
    \parshape 1 \@totalleftmargin \linewidth
    \sbox\@labels{\makebox[0pt][r]{\unhbox\@labels}}%
  \fi
  \ignorespaces
}{}{}
\pretocmd{\@thm}{\indentbyheadfalse}{}{}
\makeatother

So it'd work like this:

\newtheoremstyle{indenteddef}% name
  {} %% Space above (default = \topsep)
  {} %% Space below (default = \topsep)
  {\indentbyhead} %% Body font
  {0pt} %% Indent amount (can't be left empty)
  {\bfseries} %% Thm head font
  {.} %%  Punctuation after thm head (default = .)
  {5pt} %% Space after thm head " " = normal interword space, "\newline" = linebreak (default: 5pt plus 1pt minus 1pt)
  {} %% Thm head spec (default ~= \thmname{#1}\thmnumber{ #2}\thmnote{ (#3)})

\theoremstyle{indenteddef}
\newtheorem{definition}{Definition}[section]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.