展示如何在 LaTeX 中求解方程

展示如何在 LaTeX 中求解方程

是否有一個包可以讓我在數學模式下畫一條水平線,就像下面建議的那樣?

\begin{align*}
x + 2 &= 3\\ % First equation
 -2 &= -2\\  % Second equation
%% Horizontal line drawn under last equation HERE, with line as wide as 
%% first equation
x &= 1
\end{align*}

答案1

以下是一個使用array環境的解決方案,並注意在 mathbin(“+”和“-”)和 mathrel(“=”)類型的運算符周圍保留適當的間距。它還使用巨集\midrule(來自booktabs套件)來獲得水平線周圍的良好間距。

在此輸入影像描述

\documentclass{article}
\usepackage{array,amsmath,booktabs}
\begin{document}
\[
\begin{array}{ @{} r @{}>{{}}c<{{}}@{} r @{{}={}} r @{} }
x & + &  2 &  3\\
  & - &  2 & -2\\
\midrule
  &  &   x &  1\\
\end{array}
\]
\end{document}

答案2

很簡單:使用aligned

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{aligned}
x + 2 &= 3\\ % First equation
 -2 &= -2\\  % Second equation
\hline
x &= 1
\end{aligned}
\end{equation*}
\end{document}

在此輸入影像描述

更好的是,還可以使用booktabsand \midrule

\documentclass{article}
\usepackage{amsmath,booktabs}
\begin{document}
\begin{equation*}
\begin{aligned}
x + 2 &= 3\\ % First equation
 -2 &= -2\\  % Second equation
\midrule
x &= 1
\end{aligned}
\end{equation*}
\end{document}

在此輸入影像描述

答案3

用一個tabular

\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
 \begin{tabular}{>{$}r<{$}@{\,}>{$=}l<{$}}
x + 2 & 3  \\
   -2 & -2 \\ \hline
    x & 1
\end{tabular}
\end{document}

在此輸入影像描述

答案4

這裡有兩個使用的解決方案IEEEtrantools

嵌入IEEEeqnarraybox內部equation

\documentclass{article}

\usepackage{amsmath}
\usepackage{IEEEtrantools}

\begin{document}

\begin{equation*}
  \begin{IEEEeqnarraybox}{rCr}
              x + 2 &=&  3
    \\          - 2 &=& -2
    \\ \hline
    \\            x &=&  1  
  \end{IEEEeqnarraybox}
\end{equation*}

\end{document}

給出:

在此輸入影像描述

為了更好的控制,我建議使用IEEEeqnarray.

使用IEEEeqnarray

\documentclass{article}

\usepackage{IEEEtrantools}
\usepackage{booktabs}

\begin{document}

\begin{IEEEeqnarray*}{rCr}
                               x + 2 &=&  3
  \\                             - 2 &=& -2
  \\*[-1.0\normalbaselineskip] \cmidrule{1-3}
  \\*[-1.5\normalbaselineskip]     x &=&  1
\end{IEEEeqnarray*}

\end{document}

給出:

在此輸入影像描述

斯特凡·莫澤 (Stefan Moser) 寫了一篇優秀的教程IEEEtrantools

相關內容