Create command for a width

How can I put this code into command to be more organized and precise?

-
 Looks quite disciplined to me. Do you want the whole thing become a macro with lengths as arguments while keeping the rest same? – percusse Dec 9 '12 at 14:24 fine with me. I want to use the \documentclass{exam} to be able to use the \question command for the proper numbering. I just make use for \documentclass{article} for the sample code. Thank You. – Kayla Dec 9 '12 at 14:30

You can use a columntype for that:

\documentclass{article}

\usepackage{tabu,longtable}
\newcounter{myrow}
\newcommand\mybox{\fbox{X}}
\newcolumntype{Y}{>{\stepcounter{myrow}\themyrow.}l
X[3]
@{\hspace{2em}}
>{\mybox}l
@{\hspace{4pt}}
X}

\begin{document}

\begin{longtabu} to \textwidth{Y}
&
sometext
&&
some long text some long text some long text some long text
\end{longtabu}

\end{document}

-
 Instead of using & to number the text, can i use the \question command by the \documentclass{exam}to have a proper number order? And instead of writing && can i just use a name variable like \option to be more precise? But how will I define it based on the answer you have given me? – Kayla Dec 11 '12 at 15:06 yes you could use the \myquestion that you showed in the question to avoid typing the & explicitly I didn't do that as you didn't provide a usable example to bas on (a screen image of code is not as useful as a complete runnable document) You probably don't want to use \question as it will not be designed to be used in a table but you could use the question counter instead of myrow I just used that as that was what you had used. – David Carlisle Dec 11 '12 at 15:28 Should I merge my code with your answer? When I tried to replace & to \myquestion it no longer compiles. – Kayla Dec 11 '12 at 16:42 myquestion is your definition it takes two arguments and makes a whole row of the table. – David Carlisle Dec 11 '12 at 16:44 I replaced & with the \myquestion command but it do give me errors. I inserted the \newcolumntype in my file but it did not compile. – Kayla Dec 11 '12 at 16:54
show 2 more comments