我正在使用对齐环境在两行中各显示两个表达式。我希望每行中的第一个表达式左对齐,每行中的第二个表达式右对齐。每行中的第一个表达式已对齐,但我无法使每行中的第二个表达式右对齐。四边形用于减少每行中心的空白空间。
\documentclass[paper=letter,twoside,fontsize=12pt,leqno]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{microtype}
\usepackage{enumitem}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{scrlayer-scrpage}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mathtools}
\newcommand{\ceilset}{\mathsf{Ceil}}
\newcommand{\ceilf}[1]{\lceil #1 \rceil}
\begin{document}
Define the following two functions:
\begin{align*}
\quad \qquad \qquad &\wedge \colon \ceilset \times \ceilset \longrightarrow \ceilset & \text{and} && \vee \colon \ceilset \times \ceilset &\longrightarrow \ceilset \qquad \qquad \quad \\
\intertext{for each $(A, B) \in \ceilset \times \ceilset$ by the assignments}
\quad \qquad \qquad &\wedge \colon (A, B) \longmapsto A \cap B & \text{and} && \vee \colon (A, B) &\longmapsto \ceilf{A \cup B} \text{.} \qquad \qquad \quad
\end{align*}
These functions will be used shortly.
\end{document}
如果我提出的调整不是一个好主意,请提出替代方案。
答案1
使用alignat
,制作成对的“右对齐/左对齐”列,中间没有空格(您可以自己添加)。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\ceilset}{\mathsf{Ceil}}
\newcommand{\ceilf}[1]{\lceil #1 \rceil}
\begin{document}
Define the following two functions
\begin{alignat*}{3}
&\wedge \colon \ceilset \times \ceilset \longrightarrow \ceilset
&\qquad\text{and}\qquad &&
\vee \colon \ceilset \times \ceilset \longrightarrow \ceilset \\
\intertext{for each $(A, B) \in \ceilset \times \ceilset$ by the assignments}
&\wedge \colon (A, B) \longmapsto A \cap B
&\qquad\text{and}\qquad &&
\vee \colon (A, B) \longmapsto \ceilf{A \cup B} \makebox[0pt][l]{.}
\end{alignat*}
These functions will be used shortly.
\end{document}
我将句号设置为右侧悬挂,这样符号就对齐了。
您还应该考虑在楔形和 V 形处对齐:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\ceilset}{\mathsf{Ceil}}
\newcommand{\ceilf}[1]{\lceil #1 \rceil}
\begin{document}
Define the following two functions
\begin{alignat*}{2}
&\wedge \colon \ceilset \times \ceilset \longrightarrow \ceilset
&\qquad\text{and}\qquad &
\vee \colon \ceilset \times \ceilset \longrightarrow \ceilset \\
\intertext{for each $(A, B) \in \ceilset \times \ceilset$ by the assignments}
&\wedge \colon (A, B) \longmapsto A \cap B
&\qquad\text{and}\qquad &
\vee \colon (A, B) \longmapsto \ceilf{A \cup B} .
\end{alignat*}
These functions will be used shortly.
\end{document}
笔记。
amsmath
我只留下了代码所必需的包。- “functions”后面的冒号是错误的。
答案2
根据您的需要定义\ceilset
并尝试以下操作\ceilif
\documentclass[paper=letter,twoside,fontsize=12pt,leqno]{scrbook}
\usepackage{mathtools}
\begin{document}
\noindent Define the following two functions:
\begin{align*}
&\wedge \colon \ceilset \times \ceilset \longrightarrow \ceilset & & \text{and} & \vee \colon \ceilset \times \ceilset \longrightarrow \ceilset & \\
\intertext{for each $(A, B) \in \ceilset \times \ceilset $ by the assignments}
&\wedge \colon (A, B) \longmapsto A \cap B && \text{and} & \vee \colon (A, B) \longmapsto \ceilf{A \cup B} &\text{.}
\end{align*}
\end{document}
答案3
如果您还想对齐运算符:
\documentclass[paper=letter,twoside,fontsize=12pt,leqno]{scrbook}
\usepackage{mathtools}
\usepackage{showframe}
\let\ceilset=\relax
\let\ceilf=\relax
\begin{document}
Define the following two functions:
\begin{align*}
&\wedge \colon \ceilset \times \ceilset &&\longrightarrow \ceilset && \text{and} && \vee \colon \ceilset \times \ceilset &&\longrightarrow \\
\intertext{for each $(A, B) \in \ceilset \times \ceilset$ by the assignments}
&\wedge \colon (A, B) &&\longmapsto A \cap B && \text{and} && \vee \colon (A, B) &&\longmapsto \ceilf{A \cup B} \quad\text{.} \\
\end{align*}
\end{document}