![如何将文本放在括号\大括号内,使其不全是一行](https://linux22.com/image/360302/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E6%9C%AC%E6%94%BE%E5%9C%A8%E6%8B%AC%E5%8F%B7%5C%E5%A4%A7%E6%8B%AC%E5%8F%B7%E5%86%85%EF%BC%8C%E4%BD%BF%E5%85%B6%E4%B8%8D%E5%85%A8%E6%98%AF%E4%B8%80%E8%A1%8C.png)
我知道如何在括号下创建文本。注意:我的公式是假的,但我想给你举个例子。
\underbrace{203948x^{3}+209204024x^2-18909345x}_\text{How can I place a text that isn't on one long line, but aligned underneath the brace}
答案1
您可以将文本放在 的第二个参数中\underbrace
,\parbox
其宽度设置为 的第一个参数的宽度\underbrace
。但是,手动执行此操作可能很繁琐。特别是如果您有多个表达式(如帖子中所示),最好设置一个专用宏来处理格式化工作。在下面的示例中,此宏称为\bigbrace
。
\documentclass{article}
\usepackage{amsmath,ragged2e}
\newlength\mylen
\newcommand\bigbrace[2]{%
\settowidth\mylen{$\displaystyle #1$}
\underbrace{#1}_{\parbox{\mylen}{\scriptsize\Centering #2}}}
\begin{document}
\[
\bigbrace{203948x^{3}+209204024x^2-18909345x}{How can I place a text
that isn't on one long line, but aligned underneath the brace?}
\]
\end{document}
答案2
使用stackengine
手动换行符,或\boxedunderbrace
基于eqparbox
自动换行符包定义命令:文本放置在\parbox
宽度等于公式宽度的行中。它需要一个标签作为可选参数(M
默认情况下),以区分\boxedunderbrace
s 的多种用途。需要进行两次编译。
\documentclass{article}
\usepackage{amsmath,ragged2e}
\usepackage[usestackEOL]{stackengine}
\usepackage{eqparbox}
\newcommand\boxedunderbrace[3] [M] {\underbrace{\eqmakebox[#1]{$\displaystyle#2$} }_{\scriptsize\parbox{\eqboxwidth{#1}}{\centering#3}}}
\begin{document}
\[
\underbrace{203948x^{3}+209204024x^2-18909345x}_{\scriptsize\Centerstack{How can
I place a text that isn't on one long\\ line, but aligned underneath
the brace?}}
\]
\[
\boxedunderbrace[M]{203948x^{3}+209204024x^2-18909345x}{How can
I place a text that isn't on one long line, but aligned underneath the brace?}
\]
\end{document}