将文本和方程式放在框内

将文本和方程式放在框内

我有一个段落,其中包含文本、内联方程式和居中方程式,我想将所有内容放在页面水平居中的框中。这是一个关键段落,所以我想将其框起来,使其脱颖而出。我只想要一个简单的框:黑色轮廓,白色填充,没有圆角。

我查看了标题类似的问题,但找不到既有用又符合我需求的内容。如果有帮助,请参阅下面我想要放入框中的特定段落:

\documentclass[12pt article]{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

    Let $a(b) = \left\{ \begin{array}{c l} hi & \mbox{if } t^5 \mbox{ reduced} \\ t & \mbox{otherwise} \end{array} \right.$, $xyz = \left\{ \begin{array}{c l} GH & \mbox{if } tr^{\pi} \mbox{ secluded} \\ x& \mbox{otherwise} \end{array} \right.$, $s = \left\{ \begin{array}{c l} up^{-5} & \mbox{if } t^55 \mbox{ reduced} \\ lo & \mbox{otherwise} \end{array} \right.$. \\ \\

    Define the magician $M_n$ recursively, where $M_1 = \bigstar$ and 

    \begin{center} $  \begin{array}{r} M_{3} =   tr(Md) \\ M_{hat} =   norbert(2304) \\ Mtri =   solution \end{array} $ \end{center}

    where $z$ is the smallest integer such that $z \notin \{ 0 \}$. Terminate the magician at $M_{3}$ where $3$ is such that $M_{3}, ... , M_{3}$ have all already appeared in $M_1, ... , M_{t},$ i.e.

    \begin{center}

    $ Mtr = g, \underbrace{hi, hello, good day}_{\mbox{cousins}}, \underbrace{1,2,3,4,4,5}_{\mbox{enemies of first cousin of } g} , ... \ , M_{3}, M_{3}, M_{3} $

    \end{center}

    where $i$ is smallest such that $rt \neq z$.

\end{document}

谢谢!我不确定要使用什么标签 - 我欢迎任何更改。

答案1

如果你不需要在框内使用分页符,只需使用表格即可,否则请查看包framed

\documentclass[12pt article]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}

\begin{center}
\begin{tabular}{|p{0.9\linewidth}|}\hline % or any other width
\rule{0pt}{5ex}% for more vertical space
    Let $a(b) = \left\{ \begin{array}{c l} hi & \mbox{if } t^5 \mbox{ reduced} \\ t & \mbox{otherwise} \end{array} \right.$, $xyz = \left\{ \begin{array}{c l} GH & \mbox{if } tr^{\pi} \mbox{ secluded} \\ x& \mbox{otherwise} \end{array} \right.$, $s = \left\{ \begin{array}{c l} up^{-5} & \mbox{if } t^55 \mbox{ reduced} \\ lo & \mbox{otherwise} \end{array} \right.$. \\ \\

    Define the magician $M_n$ recursively, where $M_1 = \bigstar$ and 

    \begin{center} $  \begin{array}{r} M_{3} =   tr(Md) \\ M_{hat} =   norbert(2304) \\ Mtri =   solution \end{array} $ \end{center}

    where $z$ is the smallest integer such that $z \notin \{ 0 \}$. Terminate the magician at $M_{3}$ where $3$ is such that $M_{3}, ... , M_{3}$ have all already appeared in $M_1, ... , M_{t},$ i.e.

    \begin{center}
    $ Mtr = g, \underbrace{hi, hello, good day}_{\mbox{cousins}}, \underbrace{1,2,3,4,4,5}_{\mbox{enemies of first cousin of } g} , ... \ , M_{3}, M_{3}, M_{3} $
    \end{center}

    where $i$ is smallest such that $rt \neq z$.\\\hline
\end{tabular}
\end{center}

\end{document}

在此处输入图片描述

答案2

您还可以使用包裹mdframed定义自定义环境。这样做的好处是,您可以获得所有固有的灵活性tikz(如果您使用该framemethod=tikz选项),并且还可以跨页面边界工作。

笔记:

  • 我擅自重新格式化了方程式(但您可以随意根据需要进行调整)。

在此处输入图片描述

代码:

\documentclass[12pt article]{article}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{calc}
\usepackage[framemethod=tikz,xcolor=true]{mdframed}
\newmdenv[%
    leftmargin=0.5cm,
    backgroundcolor=yellow!10,%
    roundcorner=5pt,%
    tikzsetting={draw=red, line width=2.0pt}%
    ]{SpecialText}%
    

\newcommand*{\Format}[1]{\makebox[\widthof{$xyz$}][r]{$#1$}}%
\newcommand*{\PhantomLet}{\mbox{\hphantom{Let }}}%

\begin{document}
\begin{SpecialText}
Let $\Format{a(b)} = \left\{ \begin{array}{c l} hi & \mbox{if } t^5 \mbox{ reduced} \\ t & \mbox{otherwise} \end{array} \right.$,

\smallskip
\PhantomLet $\Format{xyz} = \left\{ \begin{array}{c l} GH & \mbox{if } tr^{\pi} \mbox{ secluded} \\ x& \mbox{otherwise} \end{array} \right.$,

\smallskip
\PhantomLet $\Format{s} = \left\{ \begin{array}{c l} up^{-5} & \mbox{if } t^55 \mbox{ reduced} \\ lo & \mbox{otherwise} \end{array} \right.$. \\ \\

Define the magician $M_n$ recursively, where $M_1 = \bigstar$ and 
%
\begin{align*}
    M_{3}   &=   tr(Md) \\ 
    M_{hat} &=   norbert(2304) \\ 
    Mtri    &=   solution
\end{align*}
%
where $z$ is the smallest integer such that $z \notin \{ 0 \}$. Terminate the magician at $M_{3}$ where $3$ is such that $M_{3}, ... , M_{3}$ have all already appeared in $M_1, ... , M_{t},$ i.e.
%
\[
Mtr = g, \underbrace{hi, hello, good day}_{\mbox{cousins}}, \underbrace{1,2,3,4,4,5}_{\mbox{enemies of first cousin of } g} , ... \ , M_{3}, M_{3}, M_{3}
\]
%
where $i$ is smallest such that $rt \neq z$.
\end{SpecialText}
\end{document}

答案3

您可以尝试以下操作:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{center}
\fbox{%
\begin{minipage}{.9\textwidth}
Let
\begin{align*}
a(b) &= 
  \left\{ \begin{array}{@{}c l} 
    hi & \text{if $t^5$ reduced} \\ 
    t  & \text{otherwise}
  \end{array} \right. 
&
xyz &= 
  \left\{ \begin{array}{@{}c l} 
    GH & \text{if $tr^{\pi}$ secluded} \\ 
    x  & \text{otherwise}
  \end{array} \right. 
\\
s &=
  \left\{ \begin{array}{@{}c l}
    up^{-5} & \text{if $t^{55}$ reduced} \\ 
    lo      & \text{otherwise} 
  \end{array} \right.
\end{align*}

Define the magician $M_n$ recursively, where $M_1 = \bigstar$ and 
\begin{align*}
  M_{3}   &= \textit{tr}(Md) \\
  M_{hat} &= \textit{norbert}(2304) \\ 
  Mtri    &= \textit{solution}
\end{align*}
where $z$ is the smallest integer such that $z \notin \{ 0 \}$. Terminate the magician at 
$M_{3}$ where $3$ is such that $M_{3},\dots, M_{3}$ have all already appeared in $M_1, 
\dots, M_{t}$, i.e.,
\[
Mtr = g, 
\underbrace{\text{hi, hello, good day}}_{\text{cousins}}, 
\underbrace{1,2,3,4,4,5}_{\text{enemies of first cousin of $g$}},
\dots , M_{3}, M_{3}, M_{3} 
\]
where $i$ is smallest such that $rt \neq z$.
\end{minipage}}% end of \fbox
\end{center}
\end{document}

请仔细查看代码,因为您的代码显示出许多 LaTeX 弱点,特别是在使用\mbox“多字母标识符”时。

诀窍是\fboxminipage还有其他方法。

相关内容