2016-08-31 3 views
1

저는 LaTeX 문서를 작성하고 있습니다. 하위 섹션의 이름을 가져 오는 방법이 필요합니다. 하위 섹션의 이름을 가져 오는 방법을 알고 있습니다. 번호가 매겨진다면 문제는 내 하위 섹션이 아니라는 것입니다.LaTeX - 번호가 지정되지 않은 하위 섹션의 이름을 얻으십시오.

\subsection{numbered}  
\Subsectionname %Will be "numbered" 

번호가없는 부분

내 문제 :

\let\Subsectionmark\subsectionmark 
\def\subsectionmark#1{\def\Subsectionname{#1}\Subsectionmark{#1}} 

그리고 당신은 당신의 하위 섹션의 이름을 얻기 위해 다음 코드를 사용할 필요가 서브 섹션 번호가

다음을 시도 할 때 나타납니다.

\subsection{numbered} 
\subsection*{unnumbered}  
\Subsectionname %Will be "numbered" 

번호가 지정되지 않은 하위 섹션의 이름을 얻는 쉬운 방법이 있는지 궁금합니다.

+0

참조 HTTPS를 : //tex.stackexchange.com/questions/75168/get-current-section-name-without-label – Robert

답변

2

번호가 인 기호은 번호가 지정되지 않은 섹션 단위로 번호가 매겨진 섹션 단위에서만 작동하며 마크는 업데이트되지 않습니다. 번호가 단면 부 - - 또는 \@ssect - 번호없는/주연 단면 부

우리가 \@sect의 일부로 제목을 설정 한 후, 단면 부 의 입력을 캡처 \@startsection 활용할 아래

. 제목은 단위 별 매크로 캡처 : \sectiontitle\subsection[*]위한 \section[*], \subsectiontitle를 들어,

enter image description here

\documentclass{article} 

\usepackage{etoolbox} 
\makeatletter 
\pretocmd{\@startsection}% <cmd> 
    {\@namedef{@sectype}{#1}}% <pre> 
    {}{}% <success><failure> 
\patchcmd{\@sect}% <cmd> 
    {\@xsect}% <search> 
    {\@namedef{\@sectype title}{#8}\@xsect}% <replace> 
    {}{}% <success><failure> 
\patchcmd{\@ssect}% <cmd> 
    {\@xsect}% <search> 
    {\@namedef{\@sectype title}{#5}\@xsect}% <replace> 
    {}{}% <success><failure> 
\makeatother 

\begin{document} 

\section{A section} 
Section name: \sectiontitle 

\subsection{A subsection} 
Subsection name: \subsectiontitle 

\subsection*{Another subsection} 
Subsection name: \subsectiontitle 

\end{document} 

titleref이 훨씬 더 쉽게 인터페이스 제공 등 :

\documentclass{article} 

% https://tex.stackexchange.com/q/75168/5764 
\usepackage{titleref} 
\makeatletter 
\newcommand*{\currentname}{\[email protected]} 
\makeatother 

\begin{document} 

\section{A section} 
Section name: \currentname 

\subsection{A subsection} 
Subsection name: \currentname 

\subsection*{Another subsection} 
Subsection name: \currentname 

\end{document}