如何在使用“newmdtheoremenv”创建的定理的标签和标题之间添加换行符?

如何在使用“newmdtheoremenv”创建的定理的标签和标题之间添加换行符?

我想在“文本 1”和“这是标题”之间添加一个换行符(见图)。

文本1。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{mdframed}
\mdfdefinestyle{textSty}{font=\small,backgroundcolor=green!10, linewidth=0pt, innerleftmargin=3ex, innerrightmargin=3ex, innertopmargin=3ex, innerbottommargin=3ex, innermargin=+0.5cm, outermargin =+0.5cm}
\newcounter{textCounter}
\newmdtheoremenv[style=textSty]{myText}[textCounter]{Text}
\begin{document}
    \begin{myText}
      \begin{center}
        \textsc{This is the title} \\
        \textit{This is the author}  
      \end{center}
  This is the text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. 
    \end{myText}
\end{document}

答案1

您只需要\hfill在-environment 的开头添加即可myText

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{mdframed}
\mdfdefinestyle{textSty}{
    font=\small,
    backgroundcolor=green!10,
    linewidth=0pt,
    innerleftmargin=3ex,
    innerrightmargin=3ex,
    innertopmargin=3ex,
    innerbottommargin=3ex,
    innermargin=+0.5cm,
    outermargin =+0.5cm,
}
\newcounter{textCounter}
\newmdtheoremenv[style=textSty]{myText}[textCounter]{Text}
\begin{document}
    \begin{myText}
        \hfill % <- NEW
        \begin{center}
            \textsc{This is the title} \\
            \textit{This is the author}
        \end{center}
        This is the text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text.
    \end{myText}
\end{document}

在此处输入图片描述

相关内容