(하위)숫자가 있는 섹션, 문자가 있는 하위 섹션 - \ref는 문자만 표시합니다.

(하위)숫자가 있는 섹션, 문자가 있는 하위 섹션 - \ref는 문자만 표시합니다.

다음 코드를 시도하면 모든 것이 예상대로 작동합니다.

\documentclass{article}
%\renewcommand{\thesubsubsection}{\alph{subsubsection})}
\begin{document}
\section{A Section}
\subsection{A Subsection}
\subsubsection{A Subsubsection}
\label{testlabel}
Hello world.
\par
In \ref{testlabel} I wrote: Hello world.
\end{document}

그러면 1.1.1이 인쇄됩니다.

하지만 주석에서 명령을 활성화하면 예상되는 1.1.a) 대신 a)가 표시됩니다.

사실 저는 섹션이 a) ...로 표시되고 참조가 중괄호 없이 1.1.a로 표시되기를 원합니다.

어떤 아이디어가 있나요?

답변1

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

LaTeX 카운터의 경우 매크로는 참조에 사용되는 접두사입니다. 일반적으로 목록 레이블은 한 수준만 표시하고 참조는 확장된 형식을 표시하는 효과를 정확하게 얻기 위해 중첩된 열거에 사용됩니다.\[email protected]

기본 매크로는 최종 카운터의 인쇄 형식이 두 위치에서 모두 동일하다고 가정하므로 )여기에서와 같이 제거하려면 접두사 매크로가 필요하거나 egreg의 답변에서와 같이 카운터 형식에 추가하지 마십시오. , 대신 )섹션 제목 형식의 일부를 고려하세요.

\documentclass{article}
\renewcommand{\thesubsubsection}{\alph{subsubsection})}
\makeatletter
\renewcommand{\p@subsubsection}{\thesubsection.\protect\eatbracket}
\makeatother
\def\eatbracket#1#2{#1\ifx)#2\else#2\fi}

\begin{document}
\section{A Section}
\subsection{A Subsection}
\subsubsection{A Subsubsection}
\label{testlabel}
Hello world.
\par
In \ref{testlabel} I wrote: Hello world.
\end{document}

답변2

나중에 제거하는 것보다 해당 위치에 괄호를 추가하는 것이 좋습니다. 이는 다음을 간단히 재정의하여 수행할 수 있습니다 \@seccntformat.

\documentclass{article}

\makeatletter
\renewcommand{\@seccntformat}[1]{%
  \csname the#1\endcsname
  \csname suffix@#1\endcsname % this does nothing unless \suffix@... is defined
  \quad
}
% the subsubsection number is just a letter
\renewcommand{\thesubsubsection}{\alph{subsubsection}}
% but references will also have “section.subsection.” in front of the letter
\renewcommand{\p@subsubsection}{\thesubsection.}
% define \suffix@subsubsection
\newcommand{\suffix@subsubsection}{)}
\makeatother

\begin{document}

\section{A Section}
\subsection{A Subsection}
\subsubsection{A Subsubsection}\label{testlabel}

Hello world.

In \ref{testlabel} I wrote: Hello world.

\end{document}

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

이것은 또한 확장 가능합니다. 더 높은 수준에서는 a)를 유지하면서 와 제목 사이에 일반적인 단어 간 공백을 원한다고 가정해 보세요 \quad. 그런 다음 코드를 다음과 같이 수정할 수 있습니다.

\makeatletter
\renewcommand{\@seccntformat}[1]{%
  \csname the#1\endcsname
  \@ifundefined{suffix@#1}%
    {\quad}%
    {\csname suffix@#1\endcsname}%
}
% the subsubsection number is just a letter
\renewcommand{\thesubsubsection}{\alph{subsubsection}}
% but references will also have “section.subsection.” in front of the letter
\renewcommand{\p@subsubsection}{\thesubsection.}
% define \suffix@subsubsection
\newcommand{\suffix@subsubsection}{) }% parenthesis and space
\makeatother

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

목차에 대한 수정 사항이 포함된 두 번째 솔루션입니다(다시 말하지만 괄호와 제목 사이에는 일반 공백이 가장 적합해 보입니다).

\documentclass{article}

\makeatletter
\renewcommand{\@seccntformat}[1]{%
  \csname the#1\endcsname
  \@ifundefined{suffix@#1}
    {\quad}%
    {\csname suffix@#1\endcsname}%
}
% the subsubsection number is just a letter
\renewcommand{\thesubsubsection}{\alph{subsubsection}}
% but references will also have “section.subsection.” in front of the letter
\renewcommand{\p@subsubsection}{\thesubsection.}
% define \suffix@subsubsection
\newcommand{\suffix@subsubsection}{) }% parenthesis and space
\renewcommand{\l@subsubsection}[2]{%
  \@dottedtocline{3}{3.8em}{3.2em}{\let\numberline\subsubsection@numberline#1}{#2}%
}
\def\subsubsection@numberline#1{#1) }
\makeatother

\begin{document}

\tableofcontents

\section{A Section}
\subsection{A Subsection}
\subsubsection{A Subsubsection}
\label{testlabel}
Hello world.
\par
In \ref{testlabel} I wrote: Hello world.

\section{Whatever}
\end{document}

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

답변3

\thesubsubsection의 내용 \thesubsection도 제공해야 합니다 .

\documentclass{article}
\renewcommand{\thesubsubsection}{\thesubsection.\alph{subsubsection})}
\begin{document}
\section{A Section}
\subsection{A Subsection}
\subsubsection{A Subsubsection}
\label{testlabel}
Hello world.
\par
In \ref{testlabel} I wrote: Hello world. 
\end{document}

굽힐 수 있는

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

관련 정보