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.

The \framebox command aligns its contents vertically centered, but this has a tendency to produce results that are extremely visually displeasing. Case in point:

\documentclass{article}  
\usepackage{relsize}  
% Double box just to make things clearer  
\newcommand{\DoubleBox}[1]{\framebox{\framebox{\textbf{#1}}}}  
\begin{document} \noindent  
\DoubleBox{I think this is visually displeasing} \par\noindent  
\DoubleBox{\raisebox{0pt}[9pt]{I think this is an ugly hack}} \par\noindent  
\DoubleBox{\larger\raisebox{0pt}[9pt]{And said hack doesn't work for larger text}}  
\end{document}

Is there a way to fix this that "just works" so things look right at all sizes?

share|improve this question
    
What do you mean by "visually displeasing"? Of course a boldface doubly framed text is visually displeasing :), but maybe you mean something else. Did you try \strut in the argument of \DoubleBox? –  egreg Sep 12 '11 at 15:12
    
I meant the vertical alignment of the text. It looks to me like the text is placed "too high" in the box. –  kahen Sep 12 '11 at 15:13

1 Answer 1

up vote 2 down vote accepted

There are two ways of solving the problem (assuming it is a problem to begin with).

The first one is to "normalize" the height and depth via \strut:

\newcommand{\DoubleBox}[1]{\framebox{\framebox{\bfseries\strut#1}}}

Alternatively, you might ignore the depth:

\usepackage{amsmath} % for optional argument to `\smash`
\newcommand{\DoubleBox}[1]{\framebox{\framebox{\smash[b]{\bfseries#1}}}}
share|improve this answer

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.