2

I was reading this answer about generating bar codes. The bar code command is defined as:

\def\barcode#1#2#3#4#5#6#7{\begingroup%
  \dimen0=0.1em
  \def\stack##1##2{\oalign{##1\cr\hidewidth##2\hidewidth}}%
  \def\0##1{\kern##1\dimen0}%
  \def\1##1{\vrule height10ex width##1\dimen0}%
  \def\L##1{\ifcase##1\bc3211##1\or\bc2221##1\or\bc2122##1\or\bc1411##1%
    \or\bc1132##1\or\bc1231##1\or\bc1114##1\or\bc1312##1\or\bc1213##1%
    \or\bc3112##1\fi}%
  \def\R##1{\bgroup\let\next\1\let\1\0\let\0\next\L##1\egroup}%
  \def\G##1{\bgroup\let\bc\bcg\L##1\egroup}% reverse
  \def\bc##1##2##3##4##5{\stack{\0##1\1##2\0##3\1##4}##5}%
  \def\bcg##1##2##3##4##5{\stack{\0##4\1##3\0##2\1##1}##5}%
  \def\bcR##1##2##3##4##5##6{\R##1\R##2\R##3\R##4\R##5\R##6\11\01\11\09%
    \endgroup}%
  \stack{\09}#1\11\01\11\L#2%
  \ifcase#1\L#3\L#4\L#5\L#6\L#7\or\L#3\G#4\L#5\G#6\G#7%
    \or\L#3\G#4\G#5\L#6\G#7\or\L#3\G#4\G#5\G#6\L#7%
    \or\G#3\L#4\L#5\G#6\G#7\or\G#3\G#4\L#5\L#6\G#7%
    \or\G#3\G#4\G#5\L#6\L#7\or\G#3\L#4\G#5\L#6\G#7%
    \or\G#3\L#4\G#5\G#6\L#7\or\G#3\G#4\L#5\G#6\L#7%
  \fi\01\11\01\11\01\bcR}

What I do not understand is why when you draw a line with:

\stack -> \oalign -> \11 -> \vrule

It has a height of 10ex. But when you call \11 outside \stack, i.e. not in \oalign, the line has a larger height. Shouldn't the height of \vrule always be 10ex as defined? I think I do not understand what \oalign does, but I could not find anything about it while searching.

1
  • 1
    The height is 10ex, but the depth is not predetermined.
    – egreg
    Commented Mar 5, 2017 at 23:44

1 Answer 1

3

The height is always 10ex, but the depth will be as much as needed to cover the depth of the enclosing box.

The \oalign macro does a \vtop with an \halign inside (called by \ialign); the top row of the \halign contributes to the height, the bottom row to the depth. This is how the side bars are longer: not in height, but in depth.

2
  • 1
    this tugboat warning deals with the often unexpected side effect of the undetermined depth: tug.org/TUGboat/tb09-2/tb21beet-warn.pdf Commented Mar 6, 2017 at 0:05
  • @barbarabeeton Nice reminder. But here the depth of the enclosing box is set by digits, which have (essentially) the same height and depth. A “perfect” code should add a suitable fixed strut.
    – egreg
    Commented Mar 6, 2017 at 0:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .