줄에 'makebox'가 포함되어 있을 때 줄바꿈을 어떻게 관리하나요?

줄에 'makebox'가 포함되어 있을 때 줄바꿈을 어떻게 관리하나요?

exam수업 시간에 다음과 같이 빈칸 채우기 질문을 쓴다면 :

\documentclass[addpoints]{exam}

\begin{document}
\begin{questions}
\question [3] The protagonist, originally from \makebox[2in]{\dotfill}, has to travel up the \makebox[2in]{\dotfill} River to retrieve \makebox[2in]{\dotfill}.
\end{questions}
\end{document}

줄은 제대로 끊어지지 않지만 다음과 같이 페이지 가장자리까지 이어집니다.

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

줄 바꿈을 강제로 수행하면 \\허용 가능한 결과가 생성됩니다.

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

그러나 이것은 투박한 것 같습니다. 이 상황을 처리하는 더 우아한 방법이 있습니까?

답변1

공백 대신 점을 확장하도록 하면 줄바꿈이 훨씬 쉬워집니다.

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

\documentclass[addpoints]{exam}

\newcommand\mydotfill[1]{{\def\hfill{\hskip #1 plus 1fill\relax}\nolinebreak\dotfill}}
\begin{document}
\begin{questions}
\question [3] The protagonist, originally from \mydotfill{2in}, has to travel up the \mydotfill{2in} River to retrieve \mydotfill{2in}.
\end{questions}
\end{document}

관련 정보