On Tue, 2020-05-26 at 14:51 +0200, Santiago Timón wrote: > I'm trying to use a custom layout, placing checkboxes in a bunch of > columns to have an ID mechanism. But I'm having this result: > > What could be the cause? (column lines used to inspect the alignment) > > As you know, I'm not very proficient with LaTex and you'll probably > find this code quite nasty...
Well … it is LaTeX, it doesn't tend to be very nice.
Anyway, the problem is with your table definition. You are making every
column 1pt wide, which is not even wide enough to fit the heading. And
that then makes things left aligned in effect.
You should do something like:
\setlength{\tabcolsep}{2pt}
\begin{tabular}{l |c|ccccccccc c cccccccccc c cccccccccc c}
And I don't think you need the "\int_compare:nT { ##1 < 9 } { ~ }"
everywhere, not sure why you are inserting spaces there.
There is a problem though. Your code generates questions that are
nested, and it seems that the metadata ends up not being readable. i.e.
the "idprefix" question wraps the other questions.
I don't have a good idea right now how to work around that.
Btw. if you can, I would really suggest sticking a barcode into a field
instead.
Benjamin
> \ExplSyntaxOn
> \newcommand{\idprefix}[2]{
> \sdaps_qobject_begin:nnn { } { Option } {idprefix}
> \sdaps_qobject_append_var:n {idprefix}
> \sdaps_checkbox_set_type:n {singlechoice}
> #1
> \sdaps_answer:n { idprefix} \sdaps_checkbox:nn {} {#2}
> \sdaps_qobject_end:n {}
> }
>
> \newcommand{\iddigits}[1]{
> \sdaps_qobject_begin:nnn {iddigits}{Option}{iddigits_#1}
> \sdaps_qobject_append_var:n {iddigits_#1}
> \sdaps_checkbox_set_type:n {singlechoice}
>
> \int_step_inline:nnnn { 0 } { 1 } { 9 } {\sdaps_answer:n {
> 1_##1} \sdaps_checkbox:nn{2_##1}{} & \int_compare:nT { ##1 < 9 } { ~
> } }
>
> \sdaps_qobject_end:n {iddigits}
> }
>
> \newcommand{\idheader}{
> & \int_step_inline:nnnn { 0 } { 1 } { 9 } { ##1 &
> \int_compare:nT { ##1 < 9 } { ~ }}
> & \int_step_inline:nnnn { 0 } { 1 } { 9 } { ##1 &
> \int_compare:nT { ##1 < 9 } { ~ }}
> & \int_step_inline:nnnn { 0 } { 1 } { 9 } { ##1 &
> \int_compare:nT { ##1 < 9 } { ~ }} \\
> }
> \ExplSyntaxOff
>
> \question{Person-ID}
> \qbegin{sid}{Option}{Subject ID}
> \begin{tabular}{l
> |m{1pt}|m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt} c
> m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt} c
> m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt}m{1pt} c}
> \idheader
> \idprefix{D10 }{10} &\iddigits{1} & \iddigits{2} &
> \iddigits{3}\\
> \idprefix{D20 }{20} \\
> \idprefix{D21 }{21} \\
> \idprefix{D30 }{30} \\
> \idprefix{D40 }{40}
> \end{tabular}
> \qend{sid}
>
> Is there anything I'm missing?
> Thanks!
> --
> Santi
signature.asc
Description: This is a digitally signed message part
