是否可以自动减少定理的文本边距?

是否可以自动减少定理的文本边距?

我正在编写一个 LaTeX 文档,其中我将数学语句环境格式化为以下代码。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \documentclass[10pt]{report} 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \usepackage{geometry}
    \usepackage{layout}
    
    \usepackage{parskip} 
    \usepackage[hang,flushmargin]{footmisc} 
    \usepackage{fontsize} 
    \usepackage{soul} 
    \usepackage{titlesec} 
    \usepackage[T1]{fontenc} 
    \usepackage{fontspec} 
    
    \usepackage{graphicx}
    \usepackage{pdfpages}
    \usepackage{caption} 
    \usepackage{float} 
    \usepackage{hyperref} 
    
    \usepackage{enumitem} 
    \usepackage{moreenum} 
    
    \usepackage{amsmath} 
    \usepackage{amsthm}
    
    \usepackage{amssymb} 
    \usepackage{stmaryrd} 
    
    \usepackage{amsfonts} 
    \usepackage{mathrsfs} 
    \usepackage{yfonts}
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \geometry{paperheight=29.7cm,paperwidth=21cm,textwidth=17cm,textheight=25cm}
    
    \setlength{\parindent}{0.25cm}
    
    \linespread{1.5}
    
    \setlength{\parskip}{1pt}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \newtheorem{definition}[equation]{Definizione}
    
    \newtheorem{axiom}[equation]{Assioma}
    
    \newtheorem{lemma}[equation]{Lemma}
    
    \newtheorem{proposition}[equation]{Proposizione}
    
    \newtheorem{corollary}[equation]{Corollario}
    
    \newtheorem{theorem}[equation]{Teorema}
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    \usepackage{lipsum}
    
    \begin{document}
    
        \lipsum[1]
        
        \begin{theorem}[My Theorem]
            \leftskip=1cm
            \rightskip=1cm
            \normalfont
            %\setmainfont{*Actually I would like write the theorem into a particular upright font: e.g. Foothlight MT Regular, Cormorant Garamont, gfsartemisia, etc...*}
            \quad\\
            This is a Theorem formatted in my personal style.
        \end{theorem}
    
        \lipsum[2]
    \end{document}

因此,为了使该过程自动化,我尝试使用命令 \newtheoremstyle 和 \theoremstyle,但我无法指示 \leftskip 和 \rightskip 的值,也无法指示文本必须进入新行而不是进入标题的新行。

因此,我希望能够实现该过程的自动化:有人可以帮我吗?

注意:

按照我尝试使用 \newtheoremstyle 的方式:我指出文本实际上是进入新行,但标题和文本之间的空间确实很大!

\newtheoremstyle{enunciato}% The name used to refer to the new style
  {\topsep}% The vertical space above the head list, a rubber lenght (default \topsep)
  {\topsep}% The vertical space below the head list, a rubber lenght (default \topsep)
  {%A declaration of the font and other aspects of the style to use for the text in the body of the list (default \normalfont)
   \setmainfont{CormorantGaramontItalic}[
                                Path = Fonts/CormorantGaramont/ ,
                                Extension = .ttf ,
                                UprightFont = CormorantGaramond-Italic
                              ]
  }% name of font to use in the body of the theorem
  { }% The extra indentation of the first line of the list, a non-rubber lenght (default is no extra indent)
  {%A declaration of the font and other aspects of the style to use for the text in the head of the list (default \normalfont)
   \setmainfont{CormorantGaramontBold}[
                                Path = Fonts/CormorantGaramont/ ,
                                Extension = .ttf ,
                                UprightFont = CormorantGaramond-Bold
                              ]}% name of head font
  { }% The text (typically punctuation) to be inserted after the head text, including any note text.
  {\newline}% The horizontal space to be inserted after the head text and "punctuation", a rubber lenght. It cannot be completely empty. As two very specital cases it can contain either a single space charactere to indicate jus a normal interword space is required or, more suprisingly, just the command \newline to indicate that a new line should be started for the body of the list.
  { }% A non-empty value for this aargument enables a complete specification of the setting of the bead itself to be supplied; an empty value means that the layout of the "plain" theorem style is used. See below for further details.

答案1

是的你可以。

但为了你自己的理智,绝不\setmainfont在文档内部进行更改。

当然,定理标题和正文字体应该与文档相同。除非你想要一份弗兰肯斯坦文档。

\documentclass[10pt]{report}
\usepackage{amsthm}
\usepackage{etoolbox}

\usepackage{lipsum}

%%% the needed changes https://tex.stackexchange.com/a/67251/4427
\makeatletter
\patchcmd{\@thm}
  {\trivlist}
  {\list{}{\leftmargin=\theoremmargin\rightmargin=\theoremmargin\parsep=0pt}}
  {}{}
\patchcmd{\@endtheorem}{\endtrivlist}{\endlist}{}{}
\makeatother

\newcommand{\theoremmargin}{1cm}

\newtheoremstyle{enunciato}
  {\topsep}
  {\topsep}
  {\normalfont}
  {}
  {\bfseries}
  {}
  {\newline}
  {}
\theoremstyle{enunciato}
\newtheorem{definition}[equation]{Definizione}
\newtheorem{axiom}[equation]{Assioma}
\newtheorem{lemma}[equation]{Lemma}
\newtheorem{proposition}[equation]{Proposizione}
\newtheorem{corollary}[equation]{Corollario}
\newtheorem{theorem}[equation]{Teorema}


\begin{document}

\lipsum[1]

\begin{theorem}[My Theorem]
This is a Theorem formatted in my personal style.
\lipsum[3][1-2]
\end{theorem}

\lipsum[2]

\end{document}

在此处输入图片描述

如果你也想proof按照同样的方法修改,

\documentclass[10pt]{report}
\usepackage{amsthm}
\usepackage{etoolbox}

\usepackage{lipsum}

%%% the needed changes
\makeatletter
\patchcmd{\@thm}
  {\trivlist}
  {\list{}{\setup@theorem}}
  {}{}
\patchcmd{\@endtheorem}{\endtrivlist}{\endlist}{}{}
\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \list{}{\setup@theorem}%
  \item[]\textit{#1}\par\nopagebreak\noindent\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}
\newcommand{\setup@theorem}{%
  \leftmargin=\theoremmargin
  \rightmargin=\theoremmargin
  \parsep=0pt
  \listparindent=\parindent
}
\makeatother

\newcommand{\theoremmargin}{0.5cm}
\newtheoremstyle{enunciato}
  {\topsep}
  {\topsep}
  {\normalfont}
  {}
  {\bfseries}
  {}
  {\newline}
  {}
\theoremstyle{enunciato}
\newtheorem{definition}[equation]{Definizione}
\newtheorem{axiom}[equation]{Assioma}
\newtheorem{lemma}[equation]{Lemma}
\newtheorem{proposition}[equation]{Proposizione}
\newtheorem{corollary}[equation]{Corollario}
\newtheorem{theorem}[equation]{Teorema}


\begin{document}

\lipsum[1]

\begin{theorem}[My Theorem]
This is a Theorem formatted in my personal style.

\lipsum[3][1-2]
\end{theorem}

\begin{proof}
\lipsum[4][1-2]

\lipsum[5][1-2]
\end{proof}

\lipsum[2]

\end{document}

在此处输入图片描述

我觉得它很丑,但这是你的文件。

相关内容