7

Since "Thm 1.2", "Def 1.33", etc. all have about the same width, I'd like to try a layout with a fixed indentation. The actual content after the label and number should begin at the same indendation if on the same line.

In the screenshot all text behind the labels should start at the red line. And ideally, also lists would left-align to this tab.

I tried with the tabu package but it seems tabulators are not exactly the use-case for a global layout scenario like this here.

screenshot

How does one influence the layout to get this behaviour?

Edit: Here's a self-contained example:

\documentclass{article}

\usepackage[margin=1.25cm]{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{enumitem}

% amsthm theorem specifications
\theoremstyle{definition} 
\newtheorem{defn}{\sffamily Def}[section] 

\newtheorem{thm}[defn]{\sffamily Thm}
\newtheorem{lem}[defn]{\sffamily Lem}

% customize section headings
\usepackage{titlesec}
\titleformat*{\section}{\small\sffamily}

% abbreviations
\newcommand{\R} { \mathbb{R} }
\newcommand{\norm}[1] { \lVert #1 \rVert }

%%%%%%%%%%%%%%%
\begin{document}

\section{one}

\begin{defn}
$\hat{f}(\xi)=\int_\R f(x)e^{-ix\xi}dx$
\end{defn}

\begin{thm}
$|\hat{f}(\xi)| \leq \lVert{f}\rVert _1$ \\  $\hat{f} \in C(\R)$ and $\lim_{\xi \rightarrow \pm\infty}\hat{f}(\xi) = 0$
\end{thm}

{\defn    $(f \star g)(y) = \int_\R f(y-x)g(x)dx$
}

{\thm     $\norm{f \star g }_1 \leq \norm{f}_1 \norm{g}_1$
}
{\thm
\begin{enumerate}[label=(\roman*), font=\sffamily,labelindent=\parindent, leftmargin=*, align=left]    
\item $T_tf(x) = f(x-t)$
\item $M_\xi f(x) = e^{ix\xi}f(x)$
\item $D_a f(x) = a^{-1/2} f(x/a)$
\end{enumerate}
}

\end{document}
lockstep
  • 250,273
Sir Vivor
  • 205

1 Answers1

9

Update

In comments now it has been requested to indent not only the first line for each theorem-like structure, but to indent all lines; since internally amsthm uses a \trivlist to create the structures, the quickest way to achieve the desired result would be to use, foe example, etoolbox to patch some internal commands to change \trivlist to \list, thus allowing to define the desired \leftmargin value:

\documentclass{article}
\usepackage{etoolbox}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{enumitem}

\newlength\thmsep \setlength\thmsep{5.5em}% change to suit your needs

\newtheoremstyle{fixedwidthindented} {\topsep} {\topsep} {\itshape} {0pt} {\bfseries\sffamily} {} {0em} {\llap{\makebox[\thmsep][l]{% \thmname{#1}~\thmnumber{#2}\if\relax\detokenize{#3}\relax.\fi}}% \thmnote{~{\normalfont(#3).}}}

\makeatletter \patchcmd{@thm}{\trivlist}{\list{}{\leftmargin=\thmsep}}{}{} \patchcmd{@endtheorem}{\endtrivlist}{\endlist}{}{} \makeatother

\theoremstyle{fixedwidthindented} \newtheorem{thm}{Thm}[section] \newtheorem{defi}[thm]{Def}

\newlist{thmenumerate}{enumerate}{4} \setlist[thmenumerate,1]{ label=(\roman), font=\normalfont\sffamily, labelindent=\parindent, leftmargin=, align=left, }

\begin{document}

\section{Test Section} \begin{thm} A test theorem. \end{thm} \begin{defi} A test definition with some filler text just to show how the text wraps when it spans more than one line with some filler text just to show how the text wraps when it spans more than one line. \end{defi} \begin{thm} The following relations hold:
\begin{thmenumerate} \item $T_{t} f(x) = f(x-t)$ \item $M_{\xi} f(x) = e^{ix\xi}f(x)$ \item $D_{a} f(x) = a^{-1/2} f(x/a)$ \end{thmenumerate} \end{thm} \begin{thm} A test theorem with some filler text just to show how the text wraps when it spans more than one line [ M_{\xi} f(x) = e^{ix\xi}f(x) ] with some filler text just to show how the text wraps when it spans more than one line. \end{thm}

\end{document}

The result:

enter image description here

You can define a new style that uses a \makebox of the desired width to typeset the name and number for the structures; in the example below an eventual annotation will be typeset outside this box (this can also be changed if required, but the question didn't contain information about eventual annotations):

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}

\newlength\thmsep \setlength\thmsep{5.5em}% change to suit your needs

\newtheoremstyle{fixedwidth} {\topsep} {\topsep} {\itshape} {0pt} {\bfseries\sffamily} {} {0em} {\makebox[\thmsep][l]{% \thmname{#1}~\thmnumber{#2}\if\relax\detokenize{#3}\relax.\fi}% \thmnote{~{\normalfont(#3).}}}

\theoremstyle{fixedwidth} \newtheorem{thm}{Thm}[section] \newtheorem{defi}[thm]{Def}

\begin{document}

\section{Test Section} \begin{thm} A test theorem \end{thm} \begin{defi} A test definition \end{defi} \begin{thm} A test theorem \end{thm}

\end{document}

enter image description here

Change the 5.5em in \thmsep according to your needs.

Update

In the case of a list beginning in the first of a theorem, the solution is a little more involved; the first item has to receive a "special treatment"; here's a little example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{enumitem}

\newlength\thmsep \setlength\thmsep{5.5em}% change to suit your needs

\newtheoremstyle{fixedwidth} {\topsep} {\topsep} {\itshape} {0pt} {\bfseries\sffamily} {} {0em} {\makebox[\thmsep][l]{% \thmname{#1}~\thmnumber{#2}\if\relax\detokenize{#3}\relax.\fi}% \thmnote{~{\normalfont(#3).}}}

\theoremstyle{fixedwidth} \newtheorem{thm}{Thm}[section] \newtheorem{defi}[thm]{Def}

\newlist{thmenumerate}{enumerate}{4} \setlist[thmenumerate,1]{ label=(\roman*), font=\normalfont\sffamily, labelindent=\parindent, leftmargin=\dimexpr\thmsep+\labelsep\relax, align=left, start=2 } \newcommand\FirstItem{% \hangindent\leftmargini{\normalfont\sffamily(i)}\hskip\labelsep}

\begin{document}

\section{Test Section} \begin{thm} A test theorem \end{thm} \begin{defi} A test definition \end{defi} \begin{thm} \FirstItem $T_{t} f(x) = f(x-t)$ \begin{thmenumerate}
\item $M_{\xi} f(x) = e^{ix\xi}f(x)$ \item $D_{a} f(x) = a^{-1/2} f(x/a)$ \end{thmenumerate} \end{thm} \begin{thm} A test theorem with some filler text just to show how the text wraps when it spans more than one line \end{thm}

\end{document}

enter image description here

Of course, the best solution here is to add some text before the list, which is a good practice anyways (adjust the left margin for the list to suit your needs):

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{enumitem}

\newlength\thmsep \setlength\thmsep{5.5em}% change to suit your needs

\newtheoremstyle{fixedwidth} {\topsep} {\topsep} {\itshape} {0pt} {\bfseries\sffamily} {} {0em} {\makebox[\thmsep][l]{% \thmname{#1}~\thmnumber{#2}\if\relax\detokenize{#3}\relax.\fi}% \thmnote{~{\normalfont(#3).}}}

\theoremstyle{fixedwidth} \newtheorem{thm}{Thm}[section] \newtheorem{defi}[thm]{Def}

\newlist{thmenumerate}{enumerate}{4} \setlist[thmenumerate,1]{ label=(\roman*), font=\normalfont\sffamily, labelindent=\parindent, leftmargin=\dimexpr\thmsep+\labelsep\relax, align=left, }

\begin{document}

\section{Test Section} \begin{thm} A test theorem \end{thm} \begin{defi} A test definition \end{defi} \begin{thm} The following relations hold:
\begin{thmenumerate} \item $T_{t} f(x) = f(x-t)$ \item $M_{\xi} f(x) = e^{ix\xi}f(x)$ \item $D_{a} f(x) = a^{-1/2} f(x/a)$ \end{thmenumerate} \end{thm} \begin{thm} A test theorem with some filler text just to show how the text wraps when it spans more than one line \end{thm}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Thanks! It would be very nice if you could comment on how to achieve the same for the lists. I tried adding leftmargin=\thmsep to the enumerate options which kind of works, but for the first line (with the "Thm" in front of the text) I don't know how to get this evenly indented. – Sir Vivor Feb 28 '15 at 13:23
  • @SirVivor Please see my updated answer. – Gonzalo Medina Feb 28 '15 at 14:28
  • @GonzaloMedina -- for one of the theorem objects, please make the text longer so that it can be seen what a multi-line text looks like. also, as i comment on the question, item labels really look better upright. – barbara beeton Feb 28 '15 at 15:51
  • @barbarabeeton Done and done. – Gonzalo Medina Feb 28 '15 at 16:28
  • I have one more question: How would one accomplish that all the lines from a thm or defn are indented the same amount and not just the first line? Very similar to a list without labels. (I changed my mind on this and said the first line only before. I had to see it in effect in order to judge it. But I really like the clean look when all content has the same indentation). Thanks a lot! – Sir Vivor Mar 01 '15 at 17:06
  • @SirVivor You're welcome! Please see my updated answer (the first code under the "Update") section. – Gonzalo Medina Mar 01 '15 at 22:01
  • @barbarabeeton a different indentation was requested; now all lines are indented (not just the first line). I'm letting you know since you showed some interest in the resulting indentation with the settings in my initial answer. – Gonzalo Medina Mar 01 '15 at 22:02
  • thanks, gonzalo. the reason i asked was because i suspected that the person qsking the question really did want everything indented. (not that i agree with that style, but if it's wanted, ...) – barbara beeton Mar 01 '15 at 22:10
  • Thanks a lot Gonzalo! I think it looks very good now. Also both the list labels and the items are now left-aligned. Great! This layout is not meant for a regular text but for highly condensed versions of lecture notes. – Sir Vivor Mar 01 '15 at 22:30