밑줄 없이 오른쪽에 메모가 있는 LaTeX 밑줄 섹션 제목

밑줄 없이 오른쪽에 메모가 있는 LaTeX 밑줄 섹션 제목

섹션 제목에 밑줄을 긋고 싶습니다. 그러나 밑줄을 완전히 확장하지 않고 오른쪽에 참조를 넣고 싶습니다. 나는 밑줄 친 부분을 얻기 위해 sectsty와 ulem을 사용하고 있습니다. 아래는 제가 하려는 작업의 예입니다. 밑줄은 오른쪽으로 계속됩니다.

\documentclass[12pt]{article}
\usepackage{sectsty}
\usepackage[normalem]{ulem}

\sectionfont{\ulemheading{\uuline}}

\begin{document}
    \section{Section Title\hfill [Ref]}
\end{document}

답변1

나는 밑줄의 필요성을 피하는 것에 대해 @egreg가 말한 것을 두 번째로 생각합니다. 하지만 때로는 어쩔 수 없는 경우도 있습니다(예: 특정 스타일을 고집하는 다른 사람들과 작업할 때). 그래서 나는 당신이 원하는 곳으로 갈 수 있도록 도와줄 것입니다.

이 솔루션은 MWE에 있는 일반 솔루션과 마찬가지로 전체 [이중] 밑줄을 허용할 뿐만 아니라 참조에 대한 대체 옵션도 제공합니다.

\section{...}나는 당신이 정상적으로 계속 사용할 수 있도록 것들을 재정의했습니다 \section*{...}. 그러나 이제는 TOC 행을 변경하는 대신 선택적 인수가 참조에 사용됩니다.

\section[{[ref]}]{Title}
\section[\cite{articleABC}]{Title}

적절하게 재정의된 전체 예는 다음과 같습니다.

\documentclass[12pt]{article}
\usepackage{sectsty}
\usepackage[normalem]{ulem}
\usepackage{showframe} % For illustration

% Add reference functionality
\makeatletter
\sectionfont{\ulemheading{\uuline}}
\let\oldsection\section
\def\section{\@ifstar\s@section\@section}
\newcommand{\@section}[2][\relax]{\oldsection{\llap{\rlap{\hspace{\textwidth}\llap{#1}}\protect\phantom{\thesection\quad}}#2}}
\newcommand{\s@section}[2][\relax]{\oldsection*{\llap{\rlap{\hspace{\textwidth}\llap{#1}}}#2}}
\makeatother

\begin{document}
    \section[\cite{test}]{Section Title}  Regular section
    \section*[{[1]}]{Section Title} Starred section % Manually give reference
    \section{Section Title} Without reference
    \section*{Section Title} Without reference, starred section
    \setcounter{section}{100}
    \section[\cite{test}]{Section Title} With a large section number
    \section[\cite{test}]{This is a Very, Very, Very Long\\Section Title} With a very long title, you must manually break the line to avoid overlapping the reference
\end{document}

이렇게 하면 다음 섹션이 만들어집니다.

예

답변2

그러면 밑줄이 그어진 섹션 제목이 표시되지만 숫자는 그대로 유지됩니다.

\documentclass[12pt]{article}
\usepackage[normalem]{ulem}

\begin{document}
    \section{\uuline{Section Title}\hfill [Ref]}
\end{document}

관련 정보