# Theorem Name/Numbering in Margin

I have seen the previous discussion on this same issue before (see Theorem name and number in margin, note in text), however this did not resolve anything as clearly as I had hoped.

Basically, I would like to have a visible margin (i.e:- a vertical line) on the left hand side of the page. Within the margin, I would like the section numbers (but not the name), equations numbers, theorem names and their respective numbers, but I am a bit a newbie in LaTeX and am I unsure how to go about doing this.

An example with the symbol "|" denoting the position of the margin would be:

3.1. | Continuous Groups
|
Definition 3.1 | Lie Group:.....
(3.1.1.)| [SOME EQUATION HERE]
Definition 3.2 | Lie Algebra:....

Just some points of clarification (updated, based on the comments) 1. The document is one-sided, so only the left-hand side margin is of relevance. 2. Any suggestions on which theorem packages will be more suitable are welcome.

-
Just to clarify: this pretty much means your document is one-sided, so it's always the left margin, not the outer margin, right? –  Ulrich Schwarz Jun 9 '12 at 20:50
Correct, it is always the left margin of every page. –  MP1510 Jun 9 '12 at 20:58
Thank you for help on that bit. And I flexible with regards to any of the packages you have suggested as I have not yet started writing up the document (I have just been researching about this topic before I begin). –  MP1510 Jun 9 '12 at 22:00

I think the following does what you want.

The packages I have used are

• esopic to add the gray vertical bar to the margin
• titlesec to customize the section numbers using \llap
• ntheorem to create a customized definition environment- you could equivalently use amsthm, but I'm more familiar with ntheorem

I've borrowed some code/ideas from

Code:

\documentclass{report}

\usepackage{xcolor}                 % to have colors
\usepackage{eso-pic}                % put things into background
\usepackage{lipsum}                 % for sample text
\usepackage[explicit]{titlesec}     % for customizing sections
\usepackage[leqno]{amsmath}         % for mathematical content
\usepackage[amsmath]{ntheorem}      % for theorem-like environments

% customize the tag form of the equations
\makeatletter
\let\mytagform@=\tagform@
\def\tagform@#1{\maketag@@@{\hbox{\llap{(\ignorespaces#1\unskip\@@italiccorr)\hspace{1mm}}}}\kern1sp}
\renewcommand{\eqref}[1]{{\mytagform@{\ref{#1}}}}
\makeatother

% customize section
\titleformat{\section}%
{\Large\bfseries}% format
{\llap{% label
\thesection\hskip 9pt}#1}%
{0pt}% horizontal sep
{}% before

% customize subsection
\titleformat{\subsection}%
{\bfseries}% format
{\llap{% label
\thesubsection\hskip 9pt}#1}%
{0pt}% horizontal sep
{}% before

% add vertical bar- change colour and thickness as desired
\AddToShipoutPicture{% from package eso-pic: put something to the background
% 3. Text area
\AtTextLowerLeft{% put it at the left bottom of the text area
\llap{\color{gray}\rule{.1cm}{\LenToUnit\textheight}% can put spacing here, e.g \hspace{.25cm}
}%
}%
}

% margin theorem
\makeatletter
\newtheoremstyle{mymargin}%
\makeatother

% my definition
\theoremstyle{mymargin}
\theorembodyfont{}      % customize these to suit your tastes
\theoremsymbol{}
\theoremprework{}
\theorempostwork{}
\theoremseparator{}
\newtheorem{mydefinition}{Definition}
\numberwithin{mydefinition}{section}

\begin{document}
\chapter{My chapter}
\section{First section}
\lipsum[1]
\begin{mydefinition}
\lipsum[2]
$$\label{eq:myequation} f(x)=x^2$$
Test reference: \eqref{eq:myequation}
\end{mydefinition}
\end{document}
-
Wow, this is an excellent response. And just what I am looking for. Thank you very much. All I have to now is adjust the text is so it is not close to the margin, and align the equation to the line of its number, but other than that, this perfect. Thank you very much @cmhughes. –  MP1510 Jun 10 '12 at 12:28
just a question of interest, how can this be in "amsthm" as well? –  MP1510 Jun 10 '12 at 12:55
@MP1510 glad it helped; I'm afraid I'm not so familiar with amsthm. I'll see if I can come up with something. –  cmhughes Jun 10 '12 at 17:11
@MP1510 there was a small problem with the vertical alignment of the equation label- I fixed it in the edit –  cmhughes Aug 7 '12 at 16:41
@ cmhughes: thank you for the correction. I normally use the environment flalign so (for some strange reason) so this slight error never came up for the vertical alignment. –  MP1510 Aug 12 '12 at 20:13