I want to have the theorem names appear in the margin. I've tried using the margin notes to do this but I was unable to do so.

Here is a picture of what I am trying to do. The top line is how the theorem environment works by default, below is what I would like. enter image description here

Here is I what i tried to do, altough I must admit I don't have a good understanding of how to do something like this


  • 1
    Welcome to TeX SX! Could you post a compilable code of what you've tried?
    – Bernard
    Nov 29 '19 at 20:13
  • by compilable do you mean to include all the packages and the preable I've used?
    – Emily
    Nov 29 '19 at 20:26
  • Not all, but the relevant packages and a preamble, so I can compile immediately to try to see what happens.
    – Bernard
    Nov 29 '19 at 20:28
  • \newenivorment{margintheorem}[#2]{ is wrong. It should be something like \newenivorment{margintheorem}[2]{ or so.
    – user194703
    Nov 29 '19 at 21:11
  • 1
    @Schrödinger'scat: Oh, now I understand (perhaps): perhaps you interpreted my comment as a remark addressed to you! No, my advice to post only actual code was meant for the OP!
    – GuM
    Nov 29 '19 at 23:04

You can define indirectly the theorem environment:





This theorem has no attribution.

\begin{theorem}[theorem name]
This theorem has a name.


enter image description here


Your question lacks some important details, and in particular you do not specify whether or not you are using a particular package to define your “theorem-like” environments. I’ll assume that you are using amsthm.

The following solution hacks directly into amsthm's definition of the \@begintheorem command, and so applies automatically to all kinds of “theorem-like” environment (propositions, lemmas, definitions…). It is based on the use of the \marginpar command from the LaTeX kernel: this makes things a bit more complicated, because this command must be issued “in outer paragraph mode”. Indeed, I wrote the code exactly with the intent of showing that a solution based on the original \marginpar command was possible.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

% \usepackage{amsmath} % not essential, but you probably want it too
\usepackage{etoolbox} % for "\patchcmd"/"\pretocmd"

%%%%%%%% BEGIN WIZARDRY %%%%%%%%


\patchcmd{\@begintheorem}{% search for:
}{% replace with:
}{% execute if succeeded:
    \wlog{>>> 1st patch succeeded.}
}{% execute if failed:
    \wlog{>>> 1st patch FAILED!}
\pretocmd{\@begintheorem}{% prepended code:
}{% execute if succeeded:
    \wlog{>>> 2nd patch succeeded.}
}{% execute if failed:
    \wlog{>>> 2nd patch FAILED!}

    \begingroup \setbox\z@ \lastbox \endgroup
\dth@everypar = \expandafter {%
    \expandafter \@thm@marginal@note@helper
    \the \dth@everypar


%%%%%%%%  END WIZARDRY  %%%%%%%%

        [\footnotesize\raggedleft  #1]%
        {\footnotesize\raggedright #1}%
\reversemarginpar % ?

\newtheorem{lemma}  {Lemma}


This text comes before the first definition.

\begin{defin}[Important definition]
    A definition is \textbf{important} if and only if it is not

And, of course:

    An \textbf{unimportant} definition is one that is not important.

Now a theorem:

\begin{theorem}[Important Theorem]
    All theorems are important, but some theorems are more important 
    than others.

The proof rests on the following

\begin{lemma}[Important lemma]
    Not all theorems (or lemmas) are equally important.

An unimportant theorem:

    Blah blah blah\ldots

And an unimportant lemma:

    Blah blah blah\ldots

Here is a little more text.


Note the old-fashioned, “vintage” code, and its use of \expandafter… ;-)

The output:

Output of the code

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.