줄의 양쪽 끝에 텍스트가 있는 밑줄

줄의 양쪽 끝에 텍스트가 있는 밑줄

줄 양쪽 끝의 텍스트 사이에 공백을 만들고 싶습니다. 예를 들어,줄의 양쪽 끝에 있는 텍스트 사이의 공백

\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}

블랭크의 길이를 미리 알 수 없기 때문에 이 방법은 만족스럽지 않습니다.

내 문제:

  1. 에 텍스트를 넣는 방법은 무엇입니까 \hrulefill?

  2. \hrulefill(보너스 질문) 과 에 의해 생성된 수평선의 수직 위치 \underline가 다르다는 것을 알았습니다. 수평 규칙의 수직 위치를 어떻게 제어할 수 있나요?

답변1

\hrulefillcslstr의 방법이 더 강력하지만 이를 수행하는 한 가지 방법은 를 사용하여 밑줄을 사용하는 방법으로 바꾸는 것입니다 \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실행된다는 의미입니다(그러나 규칙은 낮아집니다). 실제로 우리는 설정\ifteachertrue로 설정된 경우 규칙과 규칙 사이에 너비가 0인 상자가 있습니다 .

답변3

이 방법은 \uline매크로 의 일부 재정의를 사용하여 ulem일부 텍스트의 밑줄만 인쇄합니다(텍스트 자체는 보이지 않음). (보다이 답변유사한 솔루션을 위해.)

텍스트의 양쪽에 약간의 공간을 추가하여 공백이 필요한 것보다 약간 더 커졌습니다(손글씨를 허용하기 위해). 그림에서 볼 수 있듯이 이는 여러 줄에 걸쳐 확장되는 매우 긴 "공백"도 우아하게 처리합니다.

학생용 버전은 첫 번째 \let\filltheblanks...명령을 유지하고 두 번째 명령을 주석 처리하여 만들어집니다. Teacher 버전은 첫 번째 명령에 주석을 달고 두 번째 명령을 유지합니다.

\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서문의 주석 처리를 해제 하고 교사용 버전을 받으세요.

편집, Manuel의 요청에 따라 학생의 답변을 위한 추가 공간을 남겨두었습니다. \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}

학생 사본:

여기에 이미지 설명을 입력하세요

교사 사본:

여기에 이미지 설명을 입력하세요

관련 정보