我如何创建一个新命令来将静态真和假作为第一列和第二列的标签。这些列是小框的通道。这些小框将取决于创建的问题。如果创建了四个问题,则命令将提供四行,每个行有两个小框。这就是我所说的一个例子。
我在用命令编写 .tex 文件时实际看到的
代码
\question 这是一个示例短文。\twoboxes
我仍在想这是否正确......
答案1
一个穷人的解决方案是使用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}
这些框可以自动包含在这段代码中(感谢 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}
更新:
在新的环境中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}