Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Please always add a full but minimal working example (MWE) that illustrates your problem. I had issues with the \mathbb macro because I didn't know the package which defines it. –  Martin Scharrer May 17 '11 at 11:32
add comment

3 Answers

up vote 10 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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