Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

how can I create a new command to make a static true and false as labels of the first and two columns. This columns are lanes of small boxes. This small boxes would depend on the questions created. If there are four questions created then the command will provide four rows with two small boxes.This is an example of what i am saying. two column box

what I actually visualize in coding the .tex file for with the command

Code

\question This is a sample short text. \twoboxes

i am still thinking if this can be right..

share|improve this question
    
Related: Aligning three small box together with a text –  Werner Nov 28 '12 at 15:07

1 Answer 1

up vote 5 down vote accepted

A poor man's solution using longtable:

\documentclass{article}
\usepackage{amssymb,graphicx}
\usepackage{array}
\usepackage{longtable}
\newcounter{rowno}
\setcounter{rowno}{0}
\renewcommand\arraystretch{2}
\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}
\begin{document}
\begin{longtable}{>{\stepcounter{rowno}\therowno.}cp{.5\textwidth}@{\hspace{5\tabcolsep}}cc}
\multicolumn{1}{r}{}&  & \fbox{\parbox{.75cm}{True}} & \fbox{\parbox{.75cm}{False}}  \\
 & This is a sample text. & \mybox  & \mybox  \\
 & This is another sample short text. & \mybox  & \mybox  \\
 & This is a long line containing text and wrapping into second line without hitting the boxes & \mybox  & \mybox 
\end{longtable}

\end{document}

enter image description here

The boxes can be automatically included as in this code (Thanks to Gonzalo):

\documentclass{article}
\usepackage{amssymb,graphicx}
\usepackage{array}
\usepackage{longtable}
\newcounter{rowno}
\setcounter{rowno}{0}
\renewcommand\arraystretch{2}
\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}
\begin{document}
\begin{longtable}{>{\stepcounter{rowno}\therowno.}cp{.5\textwidth}@{\hspace{5\tabcolsep}}
>{\mybox}c >{\mybox}c }
\multicolumn{1}{r}{}&  & \multicolumn{1}{c}{\fbox{\parbox{.75cm}{True}}} & \multicolumn{1}{c}{\fbox{\parbox{.75cm}{False}}} \\
 & This is a sample text. &   &   \\
 & This is another sample short text. &   &   \\
 & This is a long line containing text and wrapping into second line without hitting the boxes &   & 
\end{longtable}

\end{document}

Update:

With a new environment truefalse

\documentclass{article}
\usepackage{amssymb,graphicx}
\usepackage{array}
\usepackage{longtable}
\newcounter{tfno}
\renewcommand\arraystretch{2}
\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}
%
\newenvironment{truefalse}{%
\setcounter{tfno}{0}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{>{\stepcounter{tfno}\thetfno.}cp{.5\textwidth}@{\extracolsep{\fill}}cc}
\multicolumn{1}{r}{}&  & \fbox{\parbox{.75cm}{True}} & \fbox{\parbox{.75cm}{False}}  \\
}{%
\end{longtable}
}
\newcommand\tfquestion[1]{ & #1 & \mybox  & \mybox  \\}
\begin{document}
\begin{truefalse}
  \tfquestion{This is a sample text.}
  \tfquestion{This is another sample short text.}
  \tfquestion{This is a long line containing text and wrapping into second line without hitting the boxes}
\end{truefalse}
%
\begin{truefalse}
  \tfquestion{This is a sample text.}
  \tfquestion{This is another sample short text.}
  \tfquestion{This is a long line containing text and wrapping into second line without hitting the boxes}
\end{truefalse}

\end{document}

enter image description here

share|improve this answer
    
can true false labels also become a command?so that i will no longer put `\begin{longtable}{>{\stepcounter{rowno}\therowno.}cp{.5\textwidth}@{\hspace{5\t‌​abcolsep}} >{\mybox}c >{\mybox}c } \multicolumn{1}{r}{}& & \multicolumn{1}{c}{\fbox{\parbox{.75cm}{True}}} & \multicolumn{1}{c}{\fbox{\parbox{.75cm}{False}}} \` etc in my .tex file –  Kayla Nov 29 '12 at 14:30
    
@kayla: See the updated answer. –  Harish Kumar Nov 29 '12 at 14:45
    
I am planning to remove the automatic increment of number in \tfquestion because there is already \begin{questions} command in exam class instead when tfquestion command is used, every line of text will give the 2 small boxes. ex: \begin{questions} question \tfquestion \end{questions}`. I dont know what part of the solution you gave me is the part of automatic number increment. –  Kayla Feb 20 '13 at 2:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.