我想让两个文本列以一个符号为中心对齐。以下代码接近解决方案,但仍然存在换行问题:
\newcommand{\correspondsto}{\overset{\scriptscriptstyle\wedge}{=}}
\begin{document}
\begin{equation*}
\begin{array}{@{} @{\qquad} r @{} >{{}}l @{}}
\text{this is the first part and could be longer than one line} &\correspondsto \text{the same holds for the second cell} \\
\text{Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, } &\correspondsto \text{ Lorem Ipsum has been the industry} \\
\end{array}
\end{equation*}
\end{document}
虽然此尝试适用于短文本,但不适用于较长的文本。我需要换行符(可能手动),但居中符号仍应位于形成块的行之间,即:不行,因为对应符号应位于第二行和第三行之间,因为它们形成了一个“块”。有没有办法在 latex 中做到这一点?
答案1
这是我的建议tabularx
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{booktabs}
\newcommand{\correspondsto}{$\overset{\scriptscriptstyle\wedge}{=}$}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\begin{tabularx}{\textwidth}{@{} >{\raggedleft\arraybackslash}X@{\quad\correspondsto\quad} >{\raggedright\arraybackslash}X @{}}
this is the first part and could be longer than one line & the same holds for the second cell \\ \addlinespace
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, & Lorem Ipsum has been the industry \\
\end{tabularx}
\bigskip
\begin{tabularx}{\textwidth}{@{} >{\raggedleft\arraybackslash\hsize=1.25\hsize}X@{\quad\correspondsto\quad}>{\raggedright\arraybackslash\hsize=0.75\hsize}X @{}}
this is the first part and could be longer than one line & the same holds for the second cell \\ \addlinespace
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, & Lorem Ipsum has been the industry \\
\end{tabularx}
\end{document}
答案2
类似这样?我还将楔形改为\widehat
。如果您愿意,可以替换定义。
\documentclass{article}
\usepackage{amsmath}
%\newcommand{\correspondsto}{\overset{\scriptscriptstyle\wedge}{=}}
\newcommand{\correspondsto}{\mathrel{\widehat{=}}}
\newcommand{\correspondence}[2]{%
\parbox{0.4\displaywidth}{\raggedleft\strut\ignorespaces#1\unskip\strut}%
&\correspondsto
\parbox{0.4\displaywidth}{\raggedright\strut\ignorespaces#2\unskip\strut}%
}
\begin{document}
\begin{align*}
\correspondence{Short text}{Short text} \\
\correspondence{
this is the first part and could be longer than one line
}{
the same holds for the second cell
} \\
\correspondence{
Lorem Ipsum has been the industry's standard
dummy text ever since the 1500s,
}{
Lorem Ipsum has been the industry
} \\
\correspondence{
Lorem Ipsum has been the industry's standard
dummy text ever since the 1500s,
}{
Lorem Ipsum
}
\end{align*}
\end{document}