边缘外的编号方程和定理

边缘外的编号方程和定理

我想对我选择的行进行编号。并且编号应在 pdf 文本区域之外。编号符号是 (1)、(2),而不是 1,2。

我使用 miktex、texniccenter。和 XElatex -> pdf 我想这样做。你能告诉我代码吗?帮帮我吧~~~

在此处输入图片描述

答案1

好吧,这不是一件容易的事......我找到了解决方案,感谢@胶@大卫·卡莱尔,并查看的代码amsthm.sty

注意事项:

  1. 它触及了几个内部宏。升级后会爆炸;
  2. 它需要leqno,不知道如何使其适应双面文档(欢迎提供解决方案);
  3. 如果您移动mdframed具有不同含义的物体innerleftmarginleftmargin数字,其将失去对齐。
\documentclass[leqno]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{amsmath, amsthm}
\usepackage{mdframed}
%% Code by David Carlisle at https://tex.stackexchange.com/a/258575/38080
\makeatletter
\def\formatout#1{\hbox{\hskip1sp\m@th\llap{%
    \normalcolor\normalfont#1\hspace{1.0cm}}}}
\let\oldmaketag@@@\maketag@@@
\def\oldtagform@#1{\oldmaketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
\renewcommand{\eqref}[1]{\textup{\oldtagform@{\ref{#1}}}}
\def\maketag@@@#1{\formatout{#1}}
%
% redefine the amsthm theorem start macro to use \formatout
%
\def\@begintheorem#1#2[#3]{%
  \deferred@thm@head{\the\thm@headfont \thm@indent
    \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
    \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\thmnumber}%
    \@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
    \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
    \the\thm@headpunct
    \thmheadnl % possibly a newline.
    \hskip\thm@headsep
  }%
  \ignorespaces}%
\makeatother
\swapnumbers
\def\thmnumber#1{\formatout{(#1)}}
% https://tex.stackexchange.com/a/303245/38080
\newtheorem{thm}[equation]{Theorem}
\newtheorem{exa}[equation]{Example}
\begin{document}

Let's start with
\begin{equation}
    E=mc^2
    \label{eq:mc2}
\end{equation}
so we go to:

\begin{thm}{Einsteins:}
    $E$ is equal to $m$ $c$ squared
    \label{thE}
\end{thm}

This leads to this

\begin{exa}{Example:}
    $E$ is equal to $m$ multiplied a BIG number
    \label{exE}
\end{exa}

% innerleftmargin+leftmargin must be 0pt...
\begin{mdframed}[backgroundcolor=gray!20, innerleftmargin=0pt, linewidth=0pt]
Also
\begin{equation}
    m=E/c^2
    \label{eq:mc2i}
\end{equation}
\end{mdframed}

And the references are Eq.~\ref{eq:mc2}, Th.~\ref{thE}, Ex.~\ref{exE}.

\end{document}

其结果是:

在此处输入图片描述

相关内容