9

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?

8

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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