TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

What is the LaTeX command for boxing a number like for example 123 as:


I have seen it in a book but can't find it anywhere in TeXnicCenter, which I use.

share|improve this question
Do you want to place every number in a box, or in other words for every number to have a border? Roughly like the output of \(\fbox{1} \fbox{2} \fbox{3}\)? It would help if you supplied an image of what you want. – N.N. Jul 5 '11 at 13:40
up vote 4 down vote accepted

I don't know any packages that provide macros for this, but it can be done easy enough:


% Format macro used for every digit, adjust to your liking:






See also Good way to make \textcircled numbers? for some tips about the formatting of the digits. However it's actual for circles not boxes.

share|improve this answer
I tried to avoid any @ code here to not confuse LaTeX beginners. I like to use \expandafer .. \the\numexpr because it allows to provide the number also as counter value or macro. – Martin Scharrer Jul 5 '11 at 13:52
Note: The left line of the frames look funny, but it actually just the usual zooming/anti-aliasing issue of Adobe Reader. – Martin Scharrer Jul 5 '11 at 13:54
This is what I was looking for, thanks. – nilo de roock Jul 5 '11 at 14:00

\BoxNumbers{123} \BoxNumbers{123789}


enter image description here

share|improve this answer

A variation on the theme by Martin:

\def\@boxnumber#1{\ifx#1\relax % end

Here \boxnumber{123} will give (approximately)


share|improve this answer

Your Answer


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.