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:....

Thank you in advance.

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? Jun 9, 2012 at 20:50
  • Correct, it is always the left margin of every page.
    – M1TE5H
    Jun 9, 2012 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).
    – M1TE5H
    Jun 9, 2012 at 22:00
  • Future users may find the following an improvement on the accepted answer. tex.stackexchange.com/a/277731/18414
    – Hugh
    Nov 11, 2015 at 9:56

1 Answer 1


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


   % arara: pdflatex
% !arara: indent: {overwrite: on}

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

% customize the tag form of the equations

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

% customize subsection
{\bfseries}% format
{\llap{% label
    \thesubsection\hskip 9pt}}%
{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
{\item[\theorem@headerfont \llap{##1 ##2}]}%
{\item[\theorem@headerfont \llap{##1 ##2}| ##3\theorem@separator\hskip\labelsep]}%

% my definition
\theorembodyfont{}      % customize these to suit your tastes

\chapter{My chapter}
\section{First section}
Test reference: \eqref{eq:myequation}

  • 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.
    – M1TE5H
    Jun 10, 2012 at 12:28
  • just a question of interest, how can this be in "amsthm" as well?
    – M1TE5H
    Jun 10, 2012 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, 2012 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, 2012 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.
    – M1TE5H
    Aug 12, 2012 at 20:13

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.