\hfill 및 하이픈 연결 관련 문제

\hfill 및 하이픈 연결 관련 문제

\hfill이전 줄에서 마지막 단어에 하이픈을 사용하면 \hfill평소와 같은 방식으로 작동하지 않습니다.

\documentclass[a4paper, 12pt]{book}
\begin{document}

Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings are exceptions   \hfill go to library

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings  \hfill go to library

\end{document}

예제의 \hfill첫 번째와 같은 작업을 수행하려면 무엇을 작성해야 합니까 ?\hfill

답변1

첫 번째 솔루션은 내 솔루션을 다음과 같이 수정하는 것입니다.공간이 없으면 오른쪽 정렬된 텍스트를 다음 줄로 이동합니다.

어디에서 실패할 수 있는지 확인하기 위해 David의 솔루션도 보여줍니다.

\documentclass[a4paper, 12pt,draft]{book} % draft for showing the overfull boxes

\newcommand*{\gotoend}[1]{%
  \unskip
  {\nobreak\hfill\penalty50\ \null\nobreak
   \hfill\mbox{#1}%
   \parfillskip=0pt \finalhyphendemerits=0 \par}
}

%% David's version
\newcommand*{\Dgotoend}[1]{\unskip\hspace*{\fill}\mbox{ #1}}


\begin{document}

Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings are exceptions \gotoend{go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings \gotoend{go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but AA phonetic spellings are just bigger 
exceptions \gotoend{go to library}

David's version:

Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings are exceptions \Dgotoend{go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings \Dgotoend{go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but AA phonetic spellings are just bigger exceptions \Dgotoend{go to library}

\end{document}

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

답변2

이 동작은 실제로 하이픈 넣기와 관련이 없지만 마지막 문구가 줄을 넘어가는 것을 피하고 싶을 뿐이라고 생각합니다.

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

\documentclass[a4paper, 12pt]{book}
\begin{document}

Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings are exceptions\hspace*{\fill}\mbox{ go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings\hspace*{\fill}\mbox{ go to library}

\end{document}

다음과 같이 매크로를 만들고 egreg의 요점을 해결할 수 있습니다.

\documentclass[a4paper, 12pt,draft]{book} % draft for showing the overfull boxes


%% David's version
\newcommand*{\Dgotoend}[1]{\unskip\hfill\penalty9999\hspace*{\fill}\mbox{ #1}}


\begin{document}


David's version:

Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings are exceptions \Dgotoend{go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but phonetic spellings \Dgotoend{go to library}

AA Spellings attempt to transcribe the sounds of the language into 
alphabetic letters, but AA phonetic spellings are just bigger exceptions \Dgotoend{go to library}

\end{document}

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

관련 정보