
行の両端のテキストの間に空白を入れたい。例えば、
\begin{enumerate}
\item There \hrulefill\ in the room.
\end{enumerate}
しかし、上記は生徒用バージョンにのみ表示され、空欄に答えも印刷される教師用バージョンを作成したいと思っています。アイデアはありませんが、
\begin{enumerate}
\item There \underline{\makebox[100pt][l]{is a chair}} in the room.
\end{enumerate}
ブランクの長さが事前にわからないため、この方法は満足できるものではありません。
私の問題:
にテキストを配置するにはどうすればいいですか
\hrulefill
?\hrulefill
(ボーナス質問)とによって生成される水平線の垂直位置\underline
が異なることがわかりました。これらの水平線の垂直位置を制御するにはどうすればよいでしょうか。
答え1
\hrulefill
cslstr の方法はより堅牢ですが、これを行う 1 つの方法は、 を下線を使用するものに置き換えることです\xleaders
。
\documentclass[letter,10pt]{article}
\newcommand{\ulfrule}{\xleaders\hbox{\underline{ }}\hfill\kern0pt}
\begin{document}
\begin{enumerate}
\item There \hrulefill{} in the room.
\item There \ulfrule{} in the room.
\item There \ulfrule{}\underline{is a chair}\ulfrule{} in the room.
\end{enumerate}
\end{document}
これによって次のものが生成されます:
答えを左揃えにしたい場合は、\ulfrule{}
答えの前の先頭部分を削除します。
\documentclass[letter,10pt]{article}
\newcommand{\ulfrule}{\xleaders\hbox{\underline{ }}\hfill\kern0pt}
\begin{document}
\begin{enumerate}
\item There \hrulefill{} in the room.
\item There \ulfrule{} in the room.
\item There \underline{is a chair}\ulfrule{} in the room.
\end{enumerate}
\end{document}
さらに詳しく\xleaders
何ができるかこの回答では
答え2
簡単な実装は次のとおりです。
\documentclass{article}
\newif\ifteacher % starts out false
\newcommand{\fillanswer}[2][\fill]{%
\unskip\ \lhrulefill{#1}%
\ifteacher\makebox[0pt]{#2}\fi
\lhrulefill{#1}\ \ignorespaces}
\newcommand{\lhrulefill}[1]{%
\leavevmode
\leaders\hrule height -.3ex depth \dimexpr .3ex+.4pt\relax % define the leader
\hskip\glueexpr#1/2\relax\relax % how much it should extend
\kern0pt
}
\begin{document}
\begin{enumerate}
\item There \fillanswer{is a chair} in the room.
\item There \fillanswer[5cm]{is a chair} in the room.
\teachertrue
\item There \fillanswer{is a chair} in the room.
\item There \fillanswer[5cm]{is a chair} in the room.
\end{enumerate}
\end{document}
オプション引数のデフォルト値は\fill
、これは基本的に\hrulefill
が実行されることを意味します(ただし、ルールは下げられます)。実際には、二\ifteacher
が true に設定されている場合、ルールとそれらの間のゼロ幅のボックスが表示されます。
答え3
このメソッドは、\uline
マクロのいくつかの再定義を使用します。ulem
、テキストの下線部分のみを印刷します(テキスト自体は非表示)。(この答え同様の解決策については、
テキストの両側に少しスペースを追加したので、空白は必要以上に大きくなります (手書き入力を可能にするため)。図に示すように、これにより、複数の行にまたがる非常に長い「空白」も適切に処理されます。
学生バージョンは、最初の\let\filltheblanks...
コマンドを保持し、2 番目のコマンドをコメントして作成されます。教師バージョンは、最初のコマンドをコメントし、2 番目のコマンドを保持します。
\documentclass[]{report}
\usepackage{enumerate}
\usepackage[normalem]{ulem}
\begin{document}
\LARGE % Size seemed appropriate for this type of assignment
% Fill-in-the-blank command
\newcommand{\fillintheblank}[1]{\uline{\qquad#1\qquad}}
% For Student Version
\let\filltheblanks\phantom
% For Teacher Version
\let\filltheblanks\null
% Redefined \uline
\makeatletter
\def\UL@putbox{\ifx\UL@start\@empty \else % not inner
\vrule\@width\z@ \LA@penalty\@M
{\UL@skip\wd\UL@box \UL@leaders \kern-\UL@skip}%
\filltheblanks{\box\UL@box}%
\fi}
\makeatother
%%%%%%%%%%%%%%%%
\begin{enumerate}[1.]
\item There \fillintheblank{was a dog} in the room.
\item There \fillintheblank{was a very, large, wet and disgusting looking dog} outside my door.
\end{enumerate}
\end{document}
学生版:
教師バージョン:
答え4
の答えのバリエーション空白のオン/オフを切り替える機能を備えた、空白を埋めるバージョンのドキュメントを作成します。
\answer
連続した下線(改行あり)と\answerwords
単語ごとの下線を提供します。\TeacherCopy
序文のコメントを解除すると、教師用バージョンになります。
編集: マヌエルのリクエストに応じて、生徒の回答用に余分なスペースを残します。これは、\Huge
下線のブラックアウトを開始する前にフォント サイズを設定して、その後リセットすることで実現します (巨大なテキストは同じ幅の垂直方向に制限された罫線に変換されるため、回答に割り当てられた垂直の高さには影響しないことに注意してください)。
教師バージョンが生徒バージョンと同じ単語間隔になるように再編集されました。
および\censorruleheight
を\censorruledepth
変更して、それぞれ標高、ルールの厚さ、配置を変更できます。
\documentclass{article}
\usepackage{censor}
\usepackage{xcolor}
\usepackage{readarray}
\usepackage{ifthen}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\newcounter{index}
\def\mysize{\Huge}
\def\answer#1{\mysize\xblackout{#1}\normalsize}
\def\answerwords#1{\mysize\blackout{#1}\normalsize}
\def\TeacherCopy{%
\def\answer##1{%
\color{red}%
\getargsC{##1}%
\setcounter{index}{0}%
\whiledo{\theindex<\narg}{%
\stepcounter{index}%
\setbox0=\hbox{\mysize\csname arg\romannumeral\theindex\endcsname}%
\underline{$\vphantom{g}$%
\makebox[\wd0]{\csname arg\romannumeral\theindex\endcsname}}%
\mysize\ \normalsize%
}%
\unskip%
\color{black}%
}%
\let\answerwords\answer%
}
%\TeacherCopy
\parindent0pt
\begin{document}
\begin{enumerate}
\item And the answer to life, the universe, and everything, is \answer{forty two}.
\item The beginning six words of the Gettysburg Address are
\answerwords{Four score and seven years ago}.
\end{enumerate}
\end{document}
生徒用コピー:
教師用コピー: