如何在等式中添加一条线

如何在等式中添加一条线

我想在方程式内的文本行中引入换行符。

我所做的是:

\begin{align*}
    \frac{\text{Reactividad\ relativa \\ Hidr\'ogeno\ secundario}}{\text{Reactividad\ relativa\\ Hidr\'ogeno\ secundario}}&=d
\end{align*}

我想要重现的是等号左边的内容:

在此处输入图片描述

答案1

一种变体,使用\Centerstack命令,它会自动启动文本模式,并且可以采用可选参数来设置行的对齐方式:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage[usestackEOL]{stackengine}

\begin{document}

    \begin{equation} %% \Longstack is probably better, look at the manual for stackengine...
        \frac{\,\Centerstack[l]{Relative reactivity of \\ a secondary hydrogen}\,}%
        {\Centerstack[l]{Relative reactivity of \\ a primary hydrogen}}
        = \frac{\,\Centerstack[l]{yield of product from \\ secondary hydrogen abstraction}\Bigm / \Centerstack[l]{number of \\ secondary hydrogens}\,}%
     {\Centerstack[l]{yield of product from \\ primary hydrogen abstraction}\Bigm /\Centerstack[l]{number of \\ primary hydrogens}}%
    \end{equation}

\end{document} 

在此处输入图片描述

答案2

为这些“文本变量”定义一个合适的命令:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\tvar}[1]{%
  \textup{%
    \begin{tabular}{@{}l@{}}
    #1
    \end{tabular}%
  }%
}

\begin{document}

\begin{equation*}
\frac{\tvar{Reactividad relativa \\ Hidr\'ogeno secundario}}
     {\tvar{Reactividad relativa\\ Hidr\'ogeno primario}}
=
\frac{
      \left(\tvar{Abc def \\ ghi klm}\right)\bigg/
      \left(\tvar{Abc def \\ ghi klm}\right)
     }
     {
      \left(\tvar{Abc def \\ ghi klm}\right)\bigg/
      \left(\tvar{Abc def \\ ghi klm}\right)
     }
\end{equation*}

\end{document}

在此处输入图片描述

答案3

做这件事,这并不意味着你应该做吧。我同意@Johannes_B,使用适当的变量将大大提高可读性。

您可以使用stackengine对于这些事情:

在此处输入图片描述

但在我看来,这仍然更好:

在此处输入图片描述

完整 MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{stackengine}
\begin{document}
    \begin{equation} %% \Longstack is probably better, look at the manual for stackengine... 
        \frac{\text{\stackunder{Relative reactivity of}{a secondary hydrogen}}}%
        {\text{\stackunder{Relative reactivity of}{a primary hydrogen}}} \cdots
    \end{equation}

    \bigskip

    But this is better: 

    Call $R_2$ the relative reactivity of a secondary hydrogen, $R_1$ the relative reactivity of a primary hydrogen, \dots
    \begin{equation}
        \frac{R_2}{R_1}\cdots
    \end{equation}
\end{document}

相关内容