I want to write a macro that returns the \baselineskip multiplied with a fixed value for a given font spec. That seems to be harder than I would imagine... after some fiddling I came up with this:

\box_new:N   \baseline_box
    %\box_new:N   \baseline_box
    \hbox_set:Nn \baseline_box { #1 \rule{1pt}{\baselineskip} g }

    3\box_ht:N \baseline_box



Obviously, this doesn't work yet, otherwise I wouldn't be asking the question. The error is on the \setlength line:

! Illegal unit of measure (pt inserted).

But I don't understand why. I would even love to have a LuaTeX solution, but I don't even know how to begin with that one.


Setting a box is not expandable and so \threeLineSkip cannot expand to a length. Because of that \setlength chokes as it demands a length as argument. You can circumvent this by defining a new command for setting the length:


\box_new:N \l_MiB_baseline_box

\NewDocumentCommand \SetThreeLineSkip { mm }
  { \MiB_set_three_line_skip:Nn #1 { #2 } }

\cs_new_protected:Npn \MiB_set_three_line_skip:Nn #1#2
    \hbox_set:Nn \l_MiB_baseline_box
      { #2 \rule {1pt} {\baselineskip} g }
    \skip_set:Nn #1 { 3\box_ht:N \l_MiB_baseline_box }





  • awesome explanation! But that's quite a limitation, and the reason a LuaTeX solution would be great... not such a hassle with expansion and usable as an argument almost anywhere (just dreaming) – MiB Aug 3 '13 at 2:49
  • I am not familiar with Lua and can't judge on »not such a hassle with expansion and usable as an argument almost anywhere« but from TeX's point of of view that would mean that the corresponding Lua call must be expandable (no idea if it is). Lua or not: \setlength demands a length or something that expands to a length as argument. – clemens Aug 3 '13 at 6:14
  • The problem that something like getting the width or ht is not expandable is that "typesetting" happens at a very late state in TeX (and only then it bothers to look at fonts etc that make up the length eventually). So lua is not really helping here unless you intend to do the "typesetting" also the Lua side of the house in which case you would reprogram something like TeX inside Lua (which is not what LuaTeX is doing it is adding a Lua engine to TeX) – Frank Mittelbach Aug 28 '13 at 20:01

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.