如何使用 alignat 刷新左对齐

如何使用 alignat 刷新左对齐

有人能帮我正确对齐这个多行方程吗?我运气不太好。它太长了,一行都放不下,所以我把它分成了 4 行。我试图让 '\chemspec_\text{vit}' 后面的所有 +(#) 项都向左对齐,以消除方程之间的空白(这样所有的加号都位于彼此下方)。

\documentclass{article}
\usepackage[english]{babel} 
\usepackage{amsmath}

\begin{document}

% commands
\newcommand{\dydx}[2]{\frac{\text{d}#1}{\text{d}#2}}
\newcommand{\pRPEc}[1]{p_\text{RPE}^{(#1)}}
\newcommand{\pILMc}[1]{p_\text{ILM}^{(#1)}}
\newcommand{\kelc}[1]{k_\text{el}^{(#1)}}
\newcommand{\Sret}{S_\text{ret}}
\newcommand{\Vvit}{V_\text{vit}}
\newcommand{\SVit}{\frac{\Sret}{\Vvit}}
\newcommand{\konv}{k_\text{on}^{(v)}}
\newcommand{\koffv}{k_\text{off}^{(v)}}
\newcommand{\KDv}{K_\text{D}^{(v)}}
\newcommand{\konn}{k_\text{on}^{(n)}}
\newcommand{\koffn}{k_\text{off}^{(n)}}
\newcommand{\chemspec}{\R}
\newcommand{\area}{\text{ret}}
\newcommand{\V}{v}
\newcommand{\R}{r}
\newcommand{\VR}{c}
\newcommand{\RVR}{h}
\newcommand{\N}{n}
\newcommand{\RN}{m}
\newcommand{\VRN}{f}
\newcommand{\RVRN}{\left(n_0-\left\{\N+\RN+\VRN\right\}\right)}
\newcommand{\Rone}[1]  {\koffv \VR_#1 - 2\konv\V_#1\R_#1}   % R1
\newcommand{\Rtwo}[1]  {2\koffv \RVR_#1 - \konv\R_#1\VR_#1} % R2
\newcommand{\Rthree}[1]{\koffn \RN - \konn\R_#1\N}          % R3
\newcommand{\Rfivec}[1]{\koffv \RVRN - \konv\R_#1\VRN}      % R5c

\begin{alignat}{2}
% derivative
\dydx{\chemspec_\area}{t} &= 
% transfer
 \left(\SVit\right)\pILMc{\chemspec}\chemspec_\text{ret}                                % ret --> vit
-\left[\left(\SVit\right)\pILMc{\chemspec}+\kelc{\chemspec}\right]\chemspec_\text{vit}  % vit --> ret
% reactions
 &+\left(\Rone{\area}\right)\\              %  R1
&&+\left(\Rtwo{\area}\right)\nonumber\\     %  R2
&&+\left(\Rthree{\area}\right)\nonumber\\   %  R3
&&+\left(\Rfivec{\area}\right)\nonumber     %  R5c
\end{alignat}

\end{document}

在此处输入图片描述

编辑:我解释得不好,这就是我想要实现的:

在此处输入图片描述

答案1

&只需在每一行中添加一个额外内容:

示例输出

\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsmath,geometry}

\begin{document}

% commands
\newcommand{\dydx}[2]{\frac{\mathrm{d}#1}{\mathrm{d}#2}}
\newcommand{\pRPEc}[1]{p_{\mathrm{RPE}}^{(#1)}}
\newcommand{\pILMc}[1]{p_{\mathrm{ILM}}^{(#1)}}
\newcommand{\kelc}[1]{k_{\mathrm{el}}^{(#1)}}
\newcommand{\Sret}{S_{\mathrm{ret}}}
\newcommand{\Vvit}{V_{\mathrm{vit}}}
\newcommand{\SVit}{\frac{\Sret}{\Vvit}}
\newcommand{\konv}{k_{\mathrm{on}}^{(v)}}
\newcommand{\koffv}{k_{\mathrm{off}}^{(v)}}
\newcommand{\KDv}{K_{\mathrm{D}}^{(v)}}
\newcommand{\konn}{k_{\mathrm{on}}^{(n)}}
\newcommand{\koffn}{k_{\mathrm{off}}^{(n)}}
\newcommand{\chemspec}{\R}
\newcommand{\area}{\mathrm{ret}}
\newcommand{\V}{v}
\newcommand{\R}{r}
\newcommand{\VR}{c}
\newcommand{\RVR}{h}
\newcommand{\N}{n}
\newcommand{\RN}{m}
\newcommand{\VRN}{f}
\newcommand{\RVRN}{\bigl(n_0-\bigl\{\N+\RN+\VRN\bigr\}\bigr)}
\newcommand{\Rone}[1]  {\koffv \VR_#1 - 2\konv\V_#1\R_#1}   % R1
\newcommand{\Rtwo}[1]  {2\koffv \RVR_#1 - \konv\R_#1\VR_#1} % R2
\newcommand{\Rthree}[1]{\koffn \RN - \konn\R_#1\N}          % R3
\newcommand{\Rfivec}[1]{\koffv \RVRN - \konv\R_#1\VRN}      % R5c

\begin{alignat}{2}
% derivative
\dydx{\chemspec_\area}{t} &=
% transfer
 \Bigl(\SVit\Bigr)\pILMc{\chemspec}\chemspec_{\mathrm{ret}}                                % ret --> vit
-\Bigl[\Bigl(\SVit\Bigr)\pILMc{\chemspec}+\kelc{\chemspec}\Bigr]\chemspec_{\mathrm{vit}}  % vit --> ret
% reactions
 &&+\bigl(\Rone{\area}\bigr)\\              %  R1
&&&+\bigl(\Rtwo{\area}\bigr)\nonumber\\     %  R2
&&&+\bigl(\Rthree{\area}\bigr)\nonumber\\   %  R3
&&&+\bigl(\Rfivec{\area}\bigr)\nonumber     %  R3
\end{alignat}

\end{document}

元素的对齐方式alignat

right & left & right & left & right & left ...

其他变化:

  • 添加geometry包以获取页面宽度
  • 用于一致的排版(随周围格式的变化而变化\mathrm\text\text
  • \left...\right被特定的尺寸命令所取代,\left...\right通常太大

您可以考虑使用aligned(例如作为\begin{aligned}[t])作为最后一个块。如果需要,这将使移动到新行变得更容易。例如

第二个示例

\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsmath,geometry}

\begin{document}

% commands
\newcommand{\dydx}[2]{\frac{\mathrm{d}#1}{\mathrm{d}#2}}
\newcommand{\pRPEc}[1]{p_{\mathrm{RPE}}^{(#1)}}
\newcommand{\pILMc}[1]{p_{\mathrm{ILM}}^{(#1)}}
\newcommand{\kelc}[1]{k_{\mathrm{el}}^{(#1)}}
\newcommand{\Sret}{S_{\mathrm{ret}}}
\newcommand{\Vvit}{V_{\mathrm{vit}}}
\newcommand{\SVit}{\frac{\Sret}{\Vvit}}
\newcommand{\konv}{k_{\mathrm{on}}^{(v)}}
\newcommand{\koffv}{k_{\mathrm{off}}^{(v)}}
\newcommand{\KDv}{K_{\mathrm{D}}^{(v)}}
\newcommand{\konn}{k_{\mathrm{on}}^{(n)}}
\newcommand{\koffn}{k_{\mathrm{off}}^{(n)}}
\newcommand{\chemspec}{\R}
\newcommand{\area}{\mathrm{ret}}
\newcommand{\V}{v}
\newcommand{\R}{r}
\newcommand{\VR}{c}
\newcommand{\RVR}{h}
\newcommand{\N}{n}
\newcommand{\RN}{m}
\newcommand{\VRN}{f}
\newcommand{\RVRN}{\bigl(n_0-\bigl\{\N+\RN+\VRN\bigr\}\bigr)}
\newcommand{\Rone}[1]  {\koffv \VR_#1 - 2\konv\V_#1\R_#1}   % R1
\newcommand{\Rtwo}[1]  {2\koffv \RVR_#1 - \konv\R_#1\VR_#1} % R2
\newcommand{\Rthree}[1]{\koffn \RN - \konn\R_#1\N}          % R3
\newcommand{\Rfivec}[1]{\koffv \RVRN - \konv\R_#1\VRN}      % R5c

\begin{align}
  \dydx{\chemspec_\area}{t}
  &= \Bigl(\SVit\Bigr)\pILMc{\chemspec}\chemspec_{\mathrm{ret}}
    -\Bigl[\Bigl(\SVit\Bigr)\pILMc{\chemspec}+\kelc{\chemspec}\Bigr]
    \chemspec_{\mathrm{vit}}
    \begin{aligned}[t]
      &+\bigl(\Rone{\area}\bigr)\\
      &+\bigl(\Rtwo{\area}\bigr)\\
      &+\bigl(\Rthree{\area}\bigr)\\
      &+\bigl(\Rfivec{\area}\bigr)
    \end{aligned}
  \\
  &= \Bigl(\SVit\Bigr)\pILMc{\chemspec}\chemspec_{\mathrm{ret}}
    -\Bigl[\Bigl(\SVit\Bigr)\pILMc{\chemspec}+\kelc{\chemspec}\Bigr]
    \chemspec_{\mathrm{vit}}
  \\
  &\qquad
    \begin{aligned}[t]
      &+\bigl(\Rone{\area}\bigr)\\
      &+\bigl(\Rtwo{\area}\bigr)\\
      &+\bigl(\Rthree{\area}\bigr)\\
      &+\bigl(\Rfivec{\area}\bigr)
    \end{aligned}
        \nonumber
\end{align}

\end{document}

答案2

我建议使用这三种解决方案之一。我加载了geometry package to have more decent margins. Unrelated: the language options ofbabel` 应该使用文档类选项进行加载。

\documentclass[english]{article}
\usepackage{babel}
\usepackage{geometry}
\usepackage{mathtools}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.3pt}

% commands
\newcommand{\dydx}[2]{\frac{\text{d}#1}{\text{d}#2}}
\newcommand{\pRPEc}[1]{p_\text{RPE}^{(#1)}}
\newcommand{\pILMc}[1]{p_\text{ILM}^{(#1)}}
\newcommand{\kelc}[1]{k_\text{el}^{(#1)}}
\newcommand{\Sret}{S_\text{ret}}
\newcommand{\Vvit}{V_\text{vit}}
\newcommand{\SVit}{\frac{\Sret}{\Vvit}}
\newcommand{\konv}{k_\text{on}^{(v)}}
\newcommand{\koffv}{k_\text{off}^{(v)}}
\newcommand{\KDv}{K_\text{D}^{(v)}}
\newcommand{\konn}{k_\text{on}^{(n)}}
\newcommand{\koffn}{k_\text{off}^{(n)}}
\newcommand{\chemspec}{\R}
\newcommand{\area}{\text{ret}}
\newcommand{\V}{v}
\newcommand{\R}{r}
\newcommand{\VR}{c}
\newcommand{\RVR}{h}
\newcommand{\N}{n}
\newcommand{\RN}{m}
\newcommand{\VRN}{f}
\newcommand{\RVRN}{\left(n_0-\left\{\N+\RN+\VRN\right\}\right)}
\newcommand{\Rone}[1] {\koffv \VR_#1 - 2\konv\V_#1\R_#1} % R1
\newcommand{\Rtwo}[1] {2\koffv \RVR_#1 - \konv\R_#1\VR_#1} % R2
\newcommand{\Rthree}[1]{\koffn \RN - \konn\R_#1\N} % R3
\newcommand{\Rfivec}[1]{\koffv \RVRN - \konv\R_#1\VRN} % R5c

\begin{document}

\begin{equation}
% derivative
 \begin{aligned}
  \dydx{\chemspec_\area}{t} =
% transfer
 \left(\SVit\right)\pILMc{\chemspec}\chemspec_\text{ret} % ret --> vit
 & -\left[\left(\SVit\right)\pILMc{\chemspec}+\kelc{\chemspec}\right]\chemspec_\text{vit} % vit --> ret
 % \\
% reactions
  +\left(\Rone{\area}\right)\\ % R1 &
  &+\left(\Rtwo{\area}\right)% \\ % R2
+\left(\Rthree{\area}\right) \\ % R3&
&+\left(\Rfivec{\area}\right) % R3
\end{aligned}
\end{equation}
\bigskip
\begin{align}
% derivative
  \dydx{\chemspec_\area}{t} =
% transfer
& \left(\SVit\right)\pILMc{\chemspec}\chemspec_\text{ret}% ret --> vit
 -\left[\left(\SVit\right)\pILMc{\chemspec}+\kelc{\chemspec}\right]\chemspec_\text{vit} % vit --> ret
 % \\
% reactions
  +\left(\Rone{\area}\right)\\ % R1
  &+\left(\Rtwo{\area}\right)% \\ % R2
+\left(\Rthree{\area}\right) % R3&
+\left(\Rfivec{\area}\right) % R3
\notag
\end{align}
\bigskip
\begin{equation}
% derivative
 \begin{aligned}
  \dydx{\chemspec_\area}{t} =
% transfer
 & \left(\SVit\right)\pILMc{\chemspec}\chemspec_\text{ret} % ret --> vit
 -\left[\left(\SVit\right)\pILMc{\chemspec}+\kelc{\chemspec}\right]\chemspec_\text{vit} % vit --> ret
  \\
% reactions
  & +\left(\Rone{\area}\right) % R1
   +\left(\Rtwo{\area}\right) \\ % R2
 & +\left(\Rthree{\area}\right) % R3
  +\left(\Rfivec{\area}\right) % R3
\end{aligned}
\end{equation}

\end{document} 

在此处输入图片描述

相关内容