8

Well, this question is not new. It was asked back in 2007 in texhax, and answered at the same time.

However, I couldn't apply the patch as mentioned in the answer, so I decided to ask it here. Consider this code:

\documentclass{article}
\usepackage{amsmath,amssymb}

\begin{document}
\fbox{\begin{minipage}{6cm}
\begin{align*}
    &H(x) \colon \\
    &\qquad \textnormal{Select a random $|x|$-bit prime $q$.} \\
    &\qquad \textnormal{Let } r \in_R \mathbb{Z}^*_q \\
    &\qquad \textnormal{Output } \langle r, r^{h(x)} \bmod q \rangle
\end{align*}
\end{minipage}}
\end{document}

It generates something like this:

Output with an extra line

As you can see, there's an extra empty line above H(x).

How can I remove it?

11

Use the empheq package

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{empheq}
\begin{document}
\begin{empheq}[box=\fbox]{align*}
    &H(x) \colon \\
    &\qquad \textnormal{Select a random $|x|$-bit prime $q$.} \\
    &\qquad \textnormal{Let } r \in_R \mathbb{Z}^*_q \\
    &\qquad \textnormal{Output } \langle r, r^{h(x)} \bmod q \rangle
\end{empheq}
\end{document}

Resulting in

enter image description here

You can even make it a colorbox with

\begin{empheq}[box=\colorbox{yellow}]{align*}

enter image description here

4

Set \abovedisplayskip to 0pt:

\documentclass{article}
\usepackage{amsmath,amssymb}

\begin{document}

\fbox{\begin{minipage}{6cm}
\setlength\abovedisplayskip{0pt}
\begin{align*}
    &H(x) \colon \\
    &\qquad \textnormal{Select a random $|x|$-bit prime $q$.} \\
    &\qquad \textnormal{Let } r \in_R \mathbb{Z}^*_q \\
    &\qquad \textnormal{Output } \langle r, r^{h(x)} \bmod q \rangle
\end{align*}
\end{minipage}}

\end{document}
3

Just don't use align for this, which is a task for tabular

\fbox{\renewcommand{\arraystretch}{1.2}
  \begin{tabular}{l@{}l}
  \makebox[2em][l]{$H(x)$:}\\
  & Select a random $|x|$-bit prime $q$. \\
  & Let $r \in_R \mathbb{Z}^*_q$ \\
  & Output $\langle r, r^{h(x)} \bmod q \rangle$
  \end{tabular}}

and you don't even need to guess the width of the alignment.

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.