섹션 제목의 텍스트에 줄을 그어 지우세요

섹션 제목의 텍스트에 줄을 그어 지우세요

\st{}텍스트를 지우는 경우(취소선) 섹션 제목에는 작동하지 않는 것 같습니다 . 예를 들어, 이

\documentclass{article}
\usepackage{soul,color}
\begin{document}
\section{\st{Motivation}}\label{sec:theproblem}
In this section, we are going to explain the detail and you will see...
\end{document}

본문 텍스트에서는 제대로 작동하지만 실패합니다.

\documentclass{article}
\usepackage{soul,color}
\begin{document}
\section{Motivation}\label{sec:theproblem}
In this section, we are going to \st{explain the detail} and you will see...
\end{document}

그런데, 네, soul패키지가 포함되어 있습니다 :)

업데이트

업데이트

를 사용하면 \protect\st잘 작동하지만 버그는 을 추가하면 \usepackage{hyperref}이 오류가 발생한다는 것입니다.

! Argument of \let has an extra }.
<inserted text>
                \par
l.5 \section{\protect\st{Motivation}}
                                     \label{sec:theproblem}
?

문제는 다음에 의해 해결되었습니다.크리스티안 후퍼그의 대답에.

답변1

이 솔루션의 초기 버전

명령 의 특정 동작에는 sectioning장 제목 등으로 디자인할 콘텐츠에 대한 특별한 처리가 필요합니다. 이 경우 패키지 \st의 명령 에 대한 것입니다 soul. 보호되어야 합니다. 즉, 앞에 가 와야 합니다 \protect.

편집하다

방금 테스트했습니다. \st매크로는 이미 강력합니다. \protect실제로는 필요하지 않습니다.

\documentclass{book}
\usepackage{soul}
\begin{document}
\tableofcontents
\chapter{\protect\st{This is crossed-out}}
\end{document}

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

두 번째 편집

를 사용 하면 hyperref책갈피 및 하이퍼링크와 관련된 일반적인 문제가 발생합니다. \texorpdfstring그런 비애를 극복하는 데 사용하십시오 ;-)

\documentclass{book}
\usepackage{soul}
\usepackage[bookmarksopen=true]{hyperref}
\begin{document}
\tableofcontents
\chapter{\texorpdfstring{\st{This is crossed-out}}{This is not crossed out}}
\end{document}

답변2

user31729의 솔루션에서는 줄이 그어진 텍스트("줄이 그어져 있지 않습니다")가 제목이나 ToC에 표시되지 않습니다. 수정 사항을 표시하기 위해 영혼과 일반 텍스트가 모두 필요한 경우 다음 코드가 작동합니다.

\documentclass{article}
\usepackage{lipsum}
\usepackage{soul}
\usepackage{hyperref}
\begin{document}
  \tableofcontents
  \section{\texorpdfstring{\st{Old}{New}}{}}
  \lipsum[1]
\end{document}

샘플 출력

교차된 텍스트와 교차되지 않은 텍스트를 보여주는 이미지

관련 정보