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.

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

1 Answer 1

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 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.