我在 LaTeX 中使用了以下程式碼 -
\documentclass{article}
\usepackage{amssymb,amsmath}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{c|c}
\hline
{ $X=y+z$} & {
\parbox[c]{0.75\columnwidth}{
$C_L = \begin{cases}
min\left[\left(Re\right),\: f(B)\right]\:;\: A<4\\
f(E)\:;\:4\le E<10\\
-0.29\:;\: E\ge10
\end{cases}$\\
$f(E) = E^{3}-0.0159E^{2}-0.0204E+0.474$\\
}
}\tabularnewline \hline
\end{tabular}
\end{table}
\end{document}
C_L
在輸出中,我希望和的等號f(E)
彼此對齊。我嘗試過使用align
環境,但它不起作用。有人可以幫忙嗎?
答案1
您可以將cases
內容向右推送,數量與f(E)
使用相同
$\phantom{f(E)}\llap{$C_L$} = \begin{cases}
%...
左移形成一個右對齊、零寬度的框l
,lap
不讓C_L
影響間距。
詩。您可能想要使用\min
而不只是min
在數學模式下鍵入。
答案2
您可以使用align
由amsmath
。無論如何我看到你加載它:
\documentclass{article}
\usepackage{amssymb,amsmath}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{c|c}
\hline
{ $X=y+z$} & {
\parbox[c]{0.75\columnwidth}{
\begin{align}
C_L&= \begin{cases}
min\left[\left(Re\right),\: f(B)\right]\:;\: A<4\\
f(E)\:;\:4\le E<10\\
-0.29\:;\: E\ge10
\end{cases}\\
f(E)&= E^{3}-0.0159E^{2}-0.0204E+0.474
\end{align}
}
}\tabularnewline \hline
\end{tabular}
\end{table}
\end{document}
等號前面的&號設定需要對齊的字符,這意味著如果你在其他地方使用它,後面的字符也會對齊。
這是程式碼的輸出:
答案3
對我來說,使用aligned
環境似乎是最簡單的解決方法:
\documentclass{article}
\usepackage{amssymb,amsmath}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{c|c}
\hline
{ $X=y+z$} & {
\parbox[c]{0.75\columnwidth}{
\( \begin{aligned}
C_L&= \begin{cases}
min\left[\left(Re\right),\: f(B)\right]\:;\: A<4\\
f(E)\:;\:4\le E<10\\
-0.29\:;\: E\ge10
\end{cases}\\
f(E)&= E^{3}-0.0159E^{2}-0.0204E+0.474
\end{aligned} \)
}
}\tabularnewline \hline
\end{tabular}
\end{table}
\end{document}
需要注意兩件事:
- 在一個
\parbox
,aligned
需要將環境明確置於數學模式; - 最初的範例底部的空間比頂部的空間多;這是由最後一行之後的額外內容引起的
\\
,該內容已在此處刪除。
答案4
這只是對芭芭拉建議的評論(答案允許更好的格式)。我將使用而不是內部情況,alignedat
以便也對齊內部條件cases
\left\{
\begin{alignedat}{2}
&\min[(Re),\: f(B)]\:;&\quad A&<4\\
&f(E)\:; &4&\le E<10\\
&-0.29\:; &E&\ge10
\end{alignedat}
\right.
我還刪除了\left...\right
此外,我還從內部\min
結構,因為它們沒有做出任何貢獻。
編輯:新增視覺效果