
我想要一個跨越幾行文字並位於頁面最右側的右大括號。
像這樣的東西:
有關的 :括號 - 在文字正文旁邊加上大括號
在這裡,以下程式碼似乎不起作用:
$\left.\begin{tabular}{l}
line \\
one more line
\end{tabular}\hfill\right\}$
有沒有\hfill
可行的替代方案?
答案1
我會equation*
因為以下幾個原因而濫用:
- 建築物周圍自動垂直間距;
- 避免在建置前分頁。
環境的內容braceonright
被排版為 atabular
並重複使用以獲得正確的大括號大小。這是必要的,因為如果在-對內\hfill
則不會執行任何操作。\left
\right
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum} % for mock text
\newsavebox{\braceonrightbox}
\newenvironment{braceonright}
{%
\begin{equation*}% abuse equation* for spacing and other features
\hspace{0pt}% necessary
\begin{lrbox}{\braceonrightbox}% save the contents
\begin{tabular}{@{}l@{}}%
}
{%
\end{tabular}%
\end{lrbox}%
\usebox{\braceonrightbox}
\hspace{1000pt minus 1fil}
\left.\vphantom{\usebox{\braceonrightbox}}\right\rbrace
\end{equation*}\ignorespacesafterend
}
\begin{document}
\lipsum[1][1-6]
\begin{braceonright}
line \\
one more line
\end{braceonright}
\lipsum[2]
\end{document}
訣竅是增加一個非常大的空間(1000pt),可以縮小到實際寬度;為了使其發揮作用,「方程式」的開頭必須有一些膠水(0pt)。