4

I have the following LaTeX code:

\documentclass[a4paper]{report}

\usepackage{color}
\usepackage{hyperref}
\usepackage[usenames,dvipsnames,table]{xcolor}

\newcommand{\ADDRESS}{
\begin{minipage}[t]{0.40\textwidth}
\begin{flushright}
{\bf \textcolor{gray}{\tiny{My company}}}\\
\textcolor{gray}{\tiny{1 West 1st Avenue}}\\
\textcolor{gray}{\tiny{City Province}}\\
\textcolor{gray}{\tiny{Tel: 1-777-777-7777}}\\
\textcolor{blue}{\tiny{\href{mailto:customerservice@mycompany.com}{customerservice@mycompany.com}}}\\
\textcolor{blue}{\tiny{\href{http://www.mycompany.com/}{www.mycompany.com}}}\\
\end{flushright}
\end{minipage}
}

\begin{document}
\hfill \ADDRESS
\end{document}

However, when I compile this document I get some unwanted double spacing ... How can I get rid of the double spacing and why does the double spacing show up ?

David Carlisle
  • 757,742
MadSeb
  • 363

1 Answers1

5

The spacing "problems" stem from a local font change. If you change the font globally, it would also affect the \baselineskip, which is the apparent "double spacing":

enter image description here

\documentclass[a4paper]{report}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\usepackage[usenames,dvipsnames,table]{xcolor}% http://ctan.org/pkg/xcolor

\newcommand{\ADDRESS}{
  \begin{minipage}[t]{0.40\textwidth}
    \raggedleft\tiny%
    {\bfseries\textcolor{gray}{My company}}\\
    \textcolor{gray}{1 West 1st Avenue}\\
    \textcolor{gray}{City Province}\\
    \textcolor{gray}{Tel: 1-777-777-7777}\\
    \textcolor{blue}{\href{mailto:customerservice@mycompany.com}{customerservice@mycompany.com}}\\
    \textcolor{blue}{\href{http://www.mycompany.com/}{www.mycompany.com}}
  \end{minipage}
}

\begin{document}
\hfill \ADDRESS
\end{document}​

Note the use of switches \bfseries (for bold font) and \tiny (for font size), as well as \raggedleft to remove some vertical space added by the flushright environment. The use of \bfseries is local to the first item in your \ADDRESS.

Using Marco's suggestion, using \color{gray} and \color{blue} would also suffice in setting the colour within some scope {...}:

\documentclass[a4paper]{report}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\usepackage[usenames,dvipsnames,table]{xcolor}% http://ctan.org/pkg/xcolor

\newcommand{\ADDRESS}{
  \begin{minipage}[t]{0.40\textwidth}
    \raggedleft\tiny%
    {\color{gray}{\bfseries My company} \\
    1 West 1st Avenue \\
    City Province \\
    Tel: 1-777-777-7777} \\
    {\color{blue} \href{mailto:customerservice@mycompany.com}{customerservice@mycompany.com} \\
    \href{http://www.mycompany.com/}{www.mycompany.com}}
  \end{minipage}
}

\begin{document}
\hfill \ADDRESS
\end{document}​

Also see Will two-letter font style commands (\bf, \it,...) ever be resurrected in LaTeX?

Moriambar
  • 11,466
Werner
  • 603,163
  • 1
    @Werner: A simple \color{gray} and \color{blue} can simplify the code. You don't have any problems with unbalanced brackets. Whatever I also want to link to this answer: http://tex.stackexchange.com/questions/29448/despite-using-backslash-dollar-sign-error-persists/29449#29449 – Marco Daniel Mar 05 '12 at 18:50
  • @MarcoDaniel: Simple and effective suggestions. Thanks, added. – Werner Mar 05 '12 at 18:57