在定理环境中对齐文本

在定理环境中对齐文本

所以,我对 LaTeX 还不太熟悉,我遇到了一个问题,在互联网上找不到解决方案(可能只是我不知道如何描述这个问题)。我想像这样对齐我的定理文本

Theorem 1. Lorem ipsum dolor sit amet, consetetur
           sadipscing elitr, sed diam nonumy eirmod
           tempor invidunt ut labore et dolore magna
           aliquyam erat, sed diam voluptua. At vero
           eos et accusam et justo duo dolores et ea
           rebum.

代替

Theorem 1. Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod tempor 
invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo
duo dolores et ea rebum.

这是由以下代码生成的

\documentclass{article}

\usepackage{lipsum}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}

\begin{document}
    \begin{theorem}
        \lipsum[1]
    \end{theorem}
\end{document}

这有可能吗?就我个人而言,我更喜欢这种对齐方式,因为它可以明确哪些仍是定理的一部分,哪些不是。顺便说一句:article如果这会对此产生影响,我会使用文档类。

答案1

快速回答:

\documentclass{article}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}

\newsavebox{\mybox}

\xdef\myspbetween{0.25cm}


\newenvironment{myTheorem}[1][]
{\savebox\mybox{\hbox{Theorem \thetheorem}}%
\xdef\mdim{\the\dimexpr\wd\mybox+10pt}%
\xdef\mybdim{\the\dimexpr\textwidth-\mdim-\myspbetween}%
\noindent\begin{minipage}[t]{\mdim}%
\begin{theorem}[#1]\end{theorem}\end{minipage}\hspace{\fill}\begin{minipage}[t]{\mybdim}}
{\end{minipage}\medskip}
\begin{document}

\section{New Style}
    \begin{myTheorem}
        Here is the text that will be used and I haven't lipsum installed
    \end{myTheorem}

    \begin{myTheorem}
        Here is another text that will be used and I haven't lipsum installed
    \end{myTheorem}

    \begin{myTheorem}[Custom 3]
        Here is another text that will be used and I haven't lipsum installed
    \end{myTheorem}

\section{Old style to compare}

    \begin{theorem}
        Here is the text that will be used and I haven't lipsum installed
    \end{theorem}

    \begin{theorem}
        Here is another text that will be used and I haven't lipsum installed
    \end{theorem}

    \begin{theorem}[Custom 3]
        Here is another text that will be used and I haven't lipsum installed
    \end{theorem}
\end{document}

输出:

在此处输入图片描述

您可以通过更改来调整空间:\myspbetween

PS:“comparsion”不正确,“Ols style”也不正确..已在代码中修复。

相关内容