条件换行

条件换行

我设置了一个条件来描述公式,但无法换行。如何更改条件才能实现这一点?

\usepackage[utf8]{inputenc}
\usepackage{tabularx}
%____________________________________________________________________________________________________________
\newenvironment{conditions}
  {\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}}
  {\end{tabular}\par\vspace{\belowdisplayskip}}
%____________________________________________________________________________________________________________
\begin{document}
\begin{conditions}
    \mu_{j}^{(i)} \mathrm{d}N_{j}^{(i)} &  infinitesimal change in entropy in amount of substance from each component (i = component \&  j = phase) 
\end{conditions}
\end{document}

答案1

借助tabularx您已经加载的内容:

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
%____________________________________________________________________________________________________________
\newenvironment{conditions}
  {\par\vspace{\abovedisplayskip}\noindent\tabularx{\textwidth}{>{$}l<{$} @{${}={}$} X}}
  {\endtabularx\par\vspace{\belowdisplayskip}}
%____________________________________________________________________________________________________________
\begin{document}
\begin{conditions}
    \mu_{j}^{(i)} \mathrm{d}N_{j}^{(i)} &  infinitesimal change in entropy in amount of substance from each component (i = component \&  j = phase) 
\end{conditions}
\end{document}

答案2

leandriis 答案的一个变体,其中displaymath使用而不是手动间距。

我还添加了一个在内部使用的变体gather,因此描述可以与方程式在同一显示中。

可选参数使用可用宽度的一小部分(默认值为 0.8),可以进行修改\begin{conditions}[0.9](或任何您认为合适的值)。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{xparse}

\usepackage{lipsum} % for mock text

\NewDocumentEnvironment{conditions}{O{0.8}b}
 {%
  \[\begin{tabularx}{#1\displaywidth}{@{}>{$\displaystyle}r<{={}$}@{}X@{}}
  #2
  \end{tabularx}\]%
 }
 {}

\NewDocumentEnvironment{conditions*}{O{0.8}}
 {
  \nonumber\tabularx{#1\displaywidth}{@{}>{$\displaystyle}r<{={}$}@{}X@{}}
 }
 {
  \endtabularx
 }

\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\begin{document}

\lipsum[1][1-4]
\begin{conditions}
\mu_{j}^{(i)} \diff N_{j}^{(i)} &
  infinitesimal change in entropy in amount of  substance from 
  each component ($i=\text{component}$ and  $j=\text{phase}$)
\\
x & something else
\end{conditions}
\lipsum[1][1-4]
\begin{gather}
\int\mu_{j}^{(i)} \diff N_{j}^{(i)}=x \\
\begin{conditions*}
\mu_{j}^{(i)} \diff N_{j}^{(i)} &
  infinitesimal change in entropy in amount of  substance from 
  each component ($i=\text{component}$ and  $j=\text{phase}$)
\\
x & something else
\end{conditions*}
\end{gather}
\lipsum[1][1-4]

\end{document}

在此处输入图片描述

相关内容