4

I am writing a LaTeX document where I formatting a mathstatement environment as into the following code.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \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{mathrs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

\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}

So to automatize the process I tried to use the commands \newtheoremstyle and \theoremstyle but I was not able to indicathe the value of \leftskip and \rightskip and I was not also able to indicate that the text must be into a new line and not into the same of the title.

So I would like if it is possibile to automatize the process: could someone help me, please?

N.B.

To follow the way I tried to use \newtheoremstyle: I point out that the text is actually into a new line but the space between the title and the text is really big!

\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 Answers1

4

Yes, you can.

But, for your own sanity, never change \setmainfont inside a document.

Of course the theorem header and the body font should be the same as the document's. Unless you want a Frankenstein document.

\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}

enter image description here

If you also want to modify proof along the same line,

\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}

enter image description here

I find it ugly, but it's your document.

egreg
  • 1,121,712
  • Actually I was not thinking I shall to do the same for the environment \begin{proof}\end{proof}: could I implement the code you above wrote? – Antonio Maria Di Mauro Jan 25 '24 at 18:06
  • @AntonioMariaDiMauro I added the code, with a final comment. – egreg Jan 25 '24 at 18:17
  • Thanks for edit! Answer upvoted and approved: thanks really for the help. :-)

    P.S. Anyway I realise it could be stranger: but I strangerly find it helpfull and so I probably will not change this since the document I am writing it is only for me and since I have quasi completed it so that I actually put the question only for improve the code for next documents.

    – Antonio Maria Di Mauro Jan 25 '24 at 18:24
  • Sorry, but I observed that the proof first line of proof is inline with the title "Proof" whereas I would like it is in a new line: is it possible to do this? Finally, I tried to give the value of 0.5cm at \newcommand{\thetheoremmargin}{} and I observed that the indentation of proof title is not good. Forgive the bother. – Antonio Maria Di Mauro Jan 25 '24 at 18:36
  • @AntonioMariaDiMauro Updated. – egreg Jan 25 '24 at 18:51
  • I saw: it seems work perfectely. Thanks really!!! :-) – Antonio Maria Di Mauro Jan 25 '24 at 19:39
  • Hi, forgive the bother: implementing your last code into my document the compiler signals many errors which are called with the following formula: "Too deeply nested". I tried to test it (your last code) with a short text (if you like I can put it into the question or I can share it with Mega) but nothing changed: after some pages the problem appears. – Antonio Maria Di Mauro Jan 28 '24 at 16:13
  • 1
    Fortunately it seems I was able to adjust the code: apparently the sequence "\popQED\endtrivlist@endpefalse" must be replaced with the sequence "\popQED\endlist@endpefalse" but I would like to know your opinione about. – Antonio Maria Di Mauro Jan 28 '24 at 16:31
  • 1
    @AntonioMariaDiMauro Yes, \endtrivlist should have been \endlist. – egreg Jan 28 '24 at 16:52
  • Perfect: thanks for the reply! :-) – Antonio Maria Di Mauro Jan 28 '24 at 17:44
  • Hi, unfortunately the default indentation (which I set equal to 0.25cm) into proof environment vanished: I tried to reset it puting into your code the command \listparindent=\parindent which actually works but unfortunately it indents even the first line. Could I ask you how to not indent (only) the first line? Forgive the bother. – Antonio Maria Di Mauro Feb 15 '24 at 07:55
  • @AntonioMariaDiMauro Modified the code to get indentation. I find it even uglier than before. – egreg Feb 15 '24 at 08:36
  • Oh, thanks really for the edit!!! Your complete code works perfectly but strangely implementing it into my code does not run: however it seems I was able to implement your new snippet code by myself into the old snippet code so that it can run into my complete code ; anyway, I think I have to advice with your version it seems that the body (not the first line) of the theorem environment is indented (this is really horrible, your're right about) whereas with mine not. – Antonio Maria Di Mauro Feb 15 '24 at 17:46
  • Into the next comment my code for those who have problems implementing that's of answer. Thanks really again, you're very kind with me!!! :-) – Antonio Maria Di Mauro Feb 15 '24 at 17:46
  • \makeatletter \patchcmd{@thm} {\trivlist} {\list{}{\leftmargin=\theoremmargin \rightmargin=\theoremmargin \parsep=0pt} } {}{} \patchcmd{@endtheorem}{\endtrivlist}{\endlist}{}{} \makeatletter \renewenvironment{proof}[1][\proofname]{\par \pushQED{\qed} \normalfont \topsep6\p@@plus6\p@\relax \list{}{\leftmargin=\theoremmargin \rightmargin=\theoremmargin\parsep=0pt \listparindent=\parindent } \item[]\textit{#1}\par\nopagebreak\noindent\ignorespaces }{ \popQED\endlist@endpefalse } \makeatother

    \newcommand{\theoremmargin}{0.5cm}

    – Antonio Maria Di Mauro Feb 15 '24 at 17:46