答案1
您可以使用fbox
withphantom
轻松显示一个框,代码量最少。它非常灵活,因为您可以轻松修复取决于内部文本的大小(text
在此示例中)。
\fbox{\phantom{text}}
\fbox{\phantom{long text}}
答案2
进一步阐述mmr 的答案:
\fbox
您可以使用带有幻像数字的带框框 ( )。该\phantom
命令保留其参数所占用的空间,但实际上并不打印该参数。因此,例如\fbox{\Large\phantom{10}}
创建一个字体大小为数字 10 的框\Large
。
您可以使用 将此框放在行尾\hfill
,它将填充填充命令之前行的现有内容与其后行的内容之间的空间,例如:
\item some item\hfill\fbox{\Large\phantom{10}}
将框放在页面右侧并不总是很好看,尤其是当列表项的文本较短时。为了改善这种情况,您可以minipage
在列表周围放置一个宽度小于整个页面的环境,例如0.6\textwidth
。这会导致\hfill
填充最多 60% 的行宽而不是整个页面。
要将框项目放入按字母顺序编号的列表中,如问题屏幕截图所示,您可以使用\begin{enumerate}[label=\alph*]
。label=
语法需要enumitem
包,但调查模板已加载此包。为了与调查模板的其余部分保持一致,您可以使用额外的间距设置来设置垂直项目距离 ( itemsep
) 和左边距 ( leftmargin
)。
此类型的完整列表如下:
\begin{minipage}{.5\textwidth}
\begin{enumerate}[label=\alph*,itemsep=0ex,leftmargin=2.8em]
\item Diabetes educator\hfill\fbox{\Large\phantom{10}}
\item Dietician\hfill\fbox{\Large\phantom{10}}
\item Podiatrist\hfill\fbox{\Large\phantom{10}}
\end{enumerate}
\end{minipage}
为了使定义更易于使用,您可以为列表项定义一个新命令(\bignumber
在下面的代码中称为),并为整个列表定义一个新环境(称为bignumlist
)。在下面的代码中,列表环境有一个参数,用于确定小页面的宽度。
梅威瑟:
\documentclass[a4paper,10pt,BCOR10mm,oneside,headsepline]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{wasysym}% provides \ocircle and \Box
\usepackage{enumitem}% easy control of topsep and leftmargin for lists
\usepackage{color}% used for background color
\usepackage{forloop}% used for \Qrating and \Qlines
\usepackage{ifthen}% used for \Qitem and \QItem
\usepackage{typearea}
\areaset{17cm}{26cm}
\setlength{\topmargin}{-1cm}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\ihead{Example questionnaire created with \LaTeX}
\ohead{\pagemark}
\chead{}
\cfoot{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Beginning of questionnaire command definitions %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% 2010, 2012 by Sven Hartenstein
%% [email protected]
%% http://www.svenhartenstein.de
%% \Qq = Questionaire question. Oh, this is just too simple. It helps
%% making it easy to globally change the appearance of questions.
\newcommand{\Qq}[1]{\textbf{#1}}
%% \QO = Circle or box to be ticked. Used both by direct call and by
%% \Qrating and \Qlist.
\newcommand{\QO}{$\Box$}% or: $\ocircle$
%% \Qrating = Automatically create a rating scale with NUM steps, like
%% this: 0--0--0--0--0.
\newcounter{qr}
\newcommand{\Qrating}[1]{\QO\forloop{qr}{1}{\value{qr} < #1}{---\QO}}
%% \Qline = Again, this is very simple. It helps setting the line
%% thickness globally. Used both by direct call and by \Qlines.
\newcommand{\Qline}[1]{\noindent\rule{#1}{0.6pt}}
%% \Qlines = Insert NUM lines with width=\linewith. You can change the
%% \vskip value to adjust the spacing.
\newcounter{ql}
\newcommand{\Qlines}[1]{\forloop{ql}{0}{\value{ql}<#1}{\vskip0em\Qline{\linewidth}}}
%% \Qlist = This is an environment very similar to itemize but with
%% \QO in front of each list item. Useful for classical multiple
%% choice. Change leftmargin and topsep accourding to your taste.
\newenvironment{Qlist}{%
\renewcommand{\labelitemi}{\QO}
\begin{itemize}[leftmargin=1.5em,topsep=-.5em]
}{%
\end{itemize}
}
%% \Qtab = A "tabulator simulation". The first argument is the
%% distance from the left margin. The second argument is content which
%% is indented within the current row.
\newlength{\qt}
\newcommand{\Qtab}[2]{
\setlength{\qt}{\linewidth}
\addtolength{\qt}{-#1}
\hfill\parbox[t]{\qt}{\raggedright #2}
}
%% \Qitem = Item with automatic numbering. The first optional argument
%% can be used to create sub-items like 2a, 2b, 2c, ... The item
%% number is increased if the first argument is omitted or equals 'a'.
%% You will have to adjust this if you prefer a different numbering
%% scheme. Adjust topsep and leftmargin as needed.
\newcounter{itemnummer}
\newcommand{\Qitem}[2][]{% #1 optional, #2 notwendig
\ifthenelse{\equal{#1}{}}{\stepcounter{itemnummer}}{}
\ifthenelse{\equal{#1}{a}}{\stepcounter{itemnummer}}{}
\begin{enumerate}[topsep=2pt,leftmargin=2.8em]
\item[\textbf{\arabic{itemnummer}#1.}] #2
\end{enumerate}
}
%% \QItem = Like \Qitem but with alternating background color. This
%% might be error prone as I hard-coded some lengths (-5.25pt and
%% -3pt)! I do not yet understand why I need them.
\definecolor{bgodd}{rgb}{0.8,0.8,0.8}
\definecolor{bgeven}{rgb}{0.9,0.9,0.9}
\newcounter{itemoddeven}
\newlength{\gb}
\newcommand{\QItem}[2][]{% #1 optional, #2 notwendig
\setlength{\gb}{\linewidth}
\addtolength{\gb}{-5.25pt}
\ifthenelse{\equal{\value{itemoddeven}}{0}}{%
\noindent\colorbox{bgeven}{\hskip-3pt\begin{minipage}{\gb}\Qitem[#1]{#2}\end{minipage}}%
\stepcounter{itemoddeven}%
}{%
\noindent\colorbox{bgodd}{\hskip-3pt\begin{minipage}{\gb}\Qitem[#1]{#2}\end{minipage}}%
\setcounter{itemoddeven}{0}%
}
}
%%% command for creating a box for a hand-written number
\newcommand{\bignumber}[1]{%
\item #1\hfill\fbox{\Large\phantom{10}}%
}
%%% environment for filling in numbers
\newenvironment{bignumlist}[1]{%
\begin{minipage}{#1\textwidth}
\begin{enumerate}[label=\alph*,itemsep=0ex,leftmargin=2.8em]
}
{%
\end{enumerate}%
\end{minipage}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% End of questionnaire command definitions %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section*{About you}
\Qitem{ \Qq{How many times have you visited these health professionals?}
\begin{bignumlist}{0.6}
\bignumber{Diabetes educator}
\bignumber{Dietician}
\bignumber{Podiatrist}
\end{bignumlist}
}
\end{document}
结果: