With \makebox I would just pass [r], but how do I do it in latex3? No matter whether I use fills or flush/ragged etc, the contents stay left-aligned. I suspect the updated width does not adjust the contents (and if I set it before, updating the contents will recalculate the width, it seems).



\NewDocumentCommand{\test}{m m}
    \dim_zero_new:N \l_width_dim
    \dim_set:Nn \l_width_dim { #1 }
    \meide_test:nnn { \l_tmpa_box } { \l_width_dim } { #2 }
    \box_use:N \l_tmpa_box

\cs_new_protected:Npn \meide_test:nnn #1#2#3
    \box_clear_new:N {#1}
    \hbox_set:Nn {#1} { \hfill #3 } % also tried dotfill/flushright/raggedleft etc
    \box_set_wd:Nn {#1} {#2}



result should be aligned to the right: (\test{3em}{test})


1 Answer 1


\makebox takes a width so the alignment has a size to align to, for that you need \hbox_to_wd:nn or if setting a register, \hbox_set_to_wd:Nnn

You must log in to answer this question.

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