4

I am using an align environment to display two expressions on each of two lines. I would like the first expression in each line to be left aligned and the second expression in each line to be right aligned. The first expression in each line are aligned but I can't get the second expression in each line right aligned. The quads are used to reduce the empty space in the center of each line.

\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}

If my proposed alignment is a bad idea, please suggest an alternative.

  • Your MWE doesn't compile. Are there packages or custom macro definitions missing? – Tiuri Nov 17 at 15:48
  • 2
    What is the \ceilset and \ceilf commands? – Bernard Nov 17 at 15:51
  • My bad, forgot to check the MWE. – Jay Nov 17 at 18:12
3

Use alignat, that makes pairs of “right aligned/left aligned” columns with no intervening space (that you can add yourself).

\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}

I set the period hanging right, so the symbols are aligned.

enter image description here

You should also considering aligning at the wedge and vee:

\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}

enter image description here

Notes.

  1. I only left the package amsmath that's essential for the code.
  2. The colon after “functions” is wrong.
  • Thank you for the comment about the colon. – Jay Nov 18 at 17:03
4

Define \ceilset and \ceilif according to your needs and try the following

\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}
4

If you also want to align the operators:

\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}

demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.