![`flalign` 环境中的两行文本](https://linux22.com/image/295208/%60flalign%60%20%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84%E4%B8%A4%E8%A1%8C%E6%96%87%E6%9C%AC.png)
我想实现下图所示的效果。基本上,我想让这两行非常长的文本分成两行,如下所示。我的主要问题是,如果我将文本保持在一行中flalign
,那么整个右侧文本将向左移动。这是我的代码。
\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{nccmath}
\usepackage[margin=1in]{geometry}
\newcommand \widebox[1]{\setlength\fboxsep{6pt}\boxed {\enspace#1\enspace}}
\newcommand \dpartial[2]{\frac{\partial #1}{\partial #2}}
\newcommand \ddef[2]{\frac{d #1}{d #2}}
\newcommand \spac{\\[0.6em]}
\setlength\parindent{0pt}
\numberwithin{equation}{section}
\title{\vspace{-5em} QM Formula List}
\author{David}
\date{}
\begin{document}
\maketitle
\begin{flalign*}
&i\hbar \dpartial{\Psi}{t} = -\frac{\hbar ^2}{2m}\dpartial{^2 \Psi}{x^2}+V\Psi &&\text{Shr\"odinger Equation}\spac
&\widehat{p} = -i \hbar \dpartial{}{x} &&\text{Momentim Operator} \spac
&\widehat{H} = -\frac{\hbar ^2}{2m} \ddef{^2 \psi}{x^2} + V &&\text{Energy Operator} \spac
&-\frac{\hbar^2}{2m}\ddef{^2 \psi}{x^2} + V \psi = E \psi &&\text{Time-independent Schr\"odinger Equation} \spac
\end{flalign*}
\end{document}
答案1
将项目设置为tabular
:
\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{nccmath}
\usepackage[margin=1in]{geometry}
\newcommand \widebox[1]{\setlength\fboxsep{6pt}\boxed {\enspace#1\enspace}}
\newcommand \dpartial[2]{\frac{\partial #1}{\partial #2}}
\newcommand \ddef[2]{\frac{d #1}{d #2}}
\newcommand \spac{\\[0.6em]}
\setlength\parindent{0pt}
\numberwithin{equation}{section}
\title{\vspace{-5em} QM Formula List}
\author{David}
\date{}
\begin{document}
\maketitle
\begin{flalign*}
&i\hbar \dpartial{\Psi}{t} = -\frac{\hbar ^2}{2m}\dpartial{^2 \Psi}{x^2}+V\Psi &&\text{Shr\"odinger Equation}\spac
&\widehat{p} = -i \hbar \dpartial{}{x} &&\text{Momentim Operator} \spac
&\widehat{H} = -\frac{\hbar ^2}{2m} \ddef{^2 \psi}{x^2} + V &&\text{Energy Operator} \spac
&-\frac{\hbar^2}{2m}\ddef{^2 \psi}{x^2} + V \psi = E \psi &&\begin{tabular}{@{}l@{}}Time-independent \\ Schr\"odinger Equation\end{tabular} \spac
\end{flalign*}
\end{document}
答案2
使用parbox[length]{content}
是另一种选择。
代码
\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{nccmath}
\usepackage[margin=1in]{geometry}
\newcommand \widebox[1]{\setlength\fboxsep{6pt}\boxed {\enspace#1\enspace}}
\newcommand \dpartial[2]{\frac{\partial #1}{\partial #2}}
\newcommand \ddef[2]{\frac{d #1}{d #2}}
\newcommand \spac{\\[0.6em]}
\setlength\parindent{0pt}
\numberwithin{equation}{section}
\title{\vspace{-5em} QM Formula List}
\author{David}
\date{}
\begin{document}
\maketitle
\begin{flalign*}
&i\hbar \dpartial{\Psi}{t} = -\frac{\hbar ^2}{2m}\dpartial{^2 \Psi}{x^2}+V\Psi &&\text{Shr\"odinger Equation}\spac
&\widehat{p} = -i \hbar \dpartial{}{x} &&\text{Momentim Operator} \spac
&\widehat{H} = -\frac{\hbar ^2}{2m} \ddef{^2 \psi}{x^2} + V &&\text{Energy Operator} \spac
&-\frac{\hbar^2}{2m}\ddef{^2 \psi}{x^2} + V \psi = E \psi &&\parbox{4cm}{Time-independent Schr\"odinger Equation} \spac
\end{flalign*}
\end{document}
答案3
您的公式位于左边距。要使它们(更)居中,您应该&&
在它们前面添加一对。如果您希望它们真正居中,您可以使用环境alignat*
:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{nccmath}
\usepackage[margin=1in, showframe]{geometry}
\usepackage{stackengine}
\setstackEOL{\\}
\newcommand \widebox[1]{\setlength\fboxsep{6pt}\boxed {\enspace#1\enspace}}
\newcommand \dpartial[2]{\frac{\partial #1}{\partial #2}}
\newcommand \ddef[2]{\frac{d #1}{d #2}}
\newcommand \spac{\\[0.6em]}
\setlength\parindent{0pt}
\numberwithin{equation}{section}
\title{\vspace{-5em} QM Formula List}
\author{David}
\date{}
\begin{document}
\maketitle
\begin{flalign*}
& & &i\hbar \dpartial{\Psi}{t} = -\frac{\hbar ^2}{2m}\dpartial{^2 \Psi}{x^2}+V\Psi &&\text{Shrödinger Equation}\spac
& & &\widehat{p} = -i \hbar \dpartial{}{x} && \text{Momentum Operator}\spac
& & &\widehat{H} = -\frac{\hbar ^2}{2m} \ddef{^2 \psi}{x^2} + V &&\text{Energy Operator} \spac
& & &-\frac{\hbar^2}{2m}\ddef{^2 \psi}{x^2} + V \psi = E \psi & &\Centerstack[l]{Time-independent\\ Schrödinger Equation} \spac
\end{flalign*}
\vskip2ex
\begin{alignat*}{2}
&i\hbar \dpartial{\Psi}{t} = -\frac{\hbar ^2}{2m}\dpartial{^2 \Psi}{x^2}+V\Psi &&\text{\rlap{\hspace{4em}Shrödinger Equation}}\spac
&\widehat{p} = -i \hbar \dpartial{}{x} & &\text{\rlap{\hspace{4em}Momentum Operator}}\spac
&\widehat{H} = -\frac{\hbar ^2}{2m} \ddef{^2 \psi}{x^2} + V &&\text{\rlap{\hspace{4em}Energy Operator}} \spac
&-\frac{\hbar^2}{2m}\ddef{^2 \psi}{x^2} + V \psi = E \psi &&\rlap{\hspace{4em}\Centerstack[l]{Time-independent\\ Schrödinger Equation}} \spac
\end{alignat*}
\end{document}