我怎样才能制作以下图像
这个 TeX 命令将会非常有用。
答案1
\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}
双面文档的输出
答案2
您可以使用 minipage 环境将注释与文本分开,并使用 mdframed 为框添加颜色:
\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}