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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my MWE (minimal working example):

\documentclass[]{article}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{color}

\begin{document}
    \begin{center}
     {\setlength{\fboxsep}{2.5pt}\colorbox{Orange}{ 9}}

     {\setlength{\fboxsep}{2.5pt}\colorbox{Orange}{ 10}}
     \end{center}
\end{document}

Question

How can I make the orange box around 10 as wide as the one around 9 so they line up?

share|improve this question
up vote 11 down vote accepted

Instead of making the box containing 10 narrow, I would make box containing 9 broader.

\documentclass[]{article}
\usepackage{fancyhdr,amsmath}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{color}
\usepackage{calc}   %% provides \widthof macro


\begin{document}
    \begin{center}
     {\setlength{\fboxsep}{2.5pt}\colorbox{Orange}{\makebox[\widthof{10}][c]{9}}}

     {\setlength{\fboxsep}{2.5pt}\colorbox{Orange}{10}}
     \end{center}

     \begin{center}
     {\setlength{\fboxsep}{2.5pt}\colorbox{Orange}{9}}

     {\setlength{\fboxsep}{2.5pt}\colorbox{Orange}{\makebox[\widthof{9}][c]{10}}}
     \end{center}    

\end{document}

enter image description here

share|improve this answer
    
Worked perfectly, thank you – Jane Jan 15 '14 at 1:40

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.