12

How can i produce the following imageenter image description here

TeX commands of this would be extremely helpful.

lockstep
  • 250,273
C.S.
  • 1,379

2 Answers2

13
\documentclass[twoside]{article}
\usepackage{geometry}
\geometry{a4paper,left=3cm,right=8cm,marginparwidth=6cm}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{amsmath,amsthm}
\newtheorem{theorem}{Theorem}

\usepackage{mdframed}
\usepackage{marginnote}
\newcommand\mnote[2][0pt]{%
  \marginnote{%
    \fcolorbox{black}{black!10}{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{#2}}}[#1]}

\begin{document}

\mnote[-\fboxsep]{% a vertical optional offset
\begin{theorem}{Legendre's Theorem}
\emph{The number $n!$ contains the prime factor $p$ exactly
\begin{align*}
\sum_{k \geq 1} \left \lfloor \frac{n}{p^k} \right \rfloor
\end{align*}
times}
\begin{proof}
Left as an exercise for the reader.
\end{proof}
\end{theorem}%
}
\lipsum[1]

\newpage
foo
\mnote{% without an offset
\begin{theorem}{Legendre's Theorem}
\emph{The number $n!$ contains the prime factor $p$ exactly
\begin{align*}
\sum_{k \geq 1} \left \lfloor \frac{n}{p^k} \right \rfloor
\end{align*}
times}
\begin{proof}
Left as an exercise for the reader.
\end{proof}
\end{theorem}%
}
\lipsum[1]

\end{document}

Output for a twosided document

enter image description here

enter image description here

7

You could use a minipage environment to separate the note from the text, and use mdframed to color the box:

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{fullpage}
\usepackage{amsmath,amsthm}
\colorlet{verylightgray}{black!10!white}
\newtheorem{theorem}{Theorem}

\usepackage{mdframed}

\begin{document}
\begin{minipage}[t]{0.366\linewidth}
\begin{mdframed}[linecolor=black, backgroundcolor = verylightgray]
\textbf{Legendre's Theorem}

\emph{The number $n!$ contains the prime factor $p$ exactly
\begin{align*}
\sum_{k \geq 1} \left \lfloor \frac{n}{p^k} \right \rfloor
\end{align*}
times}
\begin{proof}
Left as an exercise for the reader.
\end{proof}
\end{mdframed}
\end{minipage}
\hfill
\begin{minipage}[t]{0.55\linewidth}
\lipsum[1] %put your text here
\end{minipage}

\end{document}

enter image description here