
moderncv
를 사용하여 수업 중 번호가 매겨진 섹션을 다시 참조하고 싶지만 \ref
그렇게 할 수 없습니다.
라는 제목의 글을 읽었습니다 moderncv 클래스에서 \ref 사용 그리고 나는 다음을 얻을 수 있었습니다:
\documentclass[11pt,a4paper]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[margin=1in]{geometry}
\usepackage{etoolbox}
\newcounter{secnumber}
\newcommand{\numbersec}{\refstepcounter{secnumber}\thesecnumber~}
\patchcmd{\section}{\sectionstyle{#1}}{\sectionstyle{\numbersec #1}}{}{}
\renewcommand\sectionstyle[1]{{%
\refstepcounter{secnumber}%
\sectionfont
\textcolor{color1}{\thesecnumber.\quad#1}%
}}
\firstname{First Name}
\familyname{Last Name}
\begin{document}
\makecvtitle
\section{A Section}
\label{sec.one}
Text goes here
\section{Another Section}
\label{sec.two}
Text goes here
\section{Yet Another Section}
\label{sec.three}
Recall in section \ref{sec.one} that we mentioned ...
\end{document}
이는 다음과 같은 출력을 제공합니다.
보시다시피, 명령을 사용한 위치에는 섹션 번호가 나타나지 않습니다 \ref
.
나는 제목의 게시물을 읽고 이 문제를 해결하려고 시도했습니다.moderncv 클래스에서 \ref 사용 그러나 나는 성공하지 못했습니다.
\ref
수업 시간 에 라벨이 붙은 번호가 매겨진 섹션을 사용하고 다시 참조할 수 있습니까 moderncv
?
메모:이것이 특이한 요청일 수도 있다는 것을 알고 있지만, 이 질문을 하는 이유는 이미 해당 moderncv
수업을 사용하여 작성한 이력서가 있고 섹션 번호가 필요한 보충 문서도 작성해야 하기 때문입니다. moderncv
CV와 보충 문서 간의 시각적 및 스타일 일관성을 유지하기 위해 이 보충 문서에 대한 클래스(수정 사항 포함)를 사용하고 싶습니다 . 보충 문서에서 참조를 요구하는 이유는 독자에게 특정 번호가 매겨진 섹션을 다시 참조하도록 요청하여 정보가 반복되는 것을 피하기 위한 것입니다.
답변1
문제는 숫자를 생성하는 데 사용되는 다소 복잡한 코드로 인해 발생합니다. 해당 코드를 단순화하면 \label
명령이 예상한 대로 작동할 것입니다. 매크로 내에서 카운터를 증가시키는 대신 명령 \sectionstyle
앞에 추가합니다 \section
. 이렇게 하면 \label
명령이 명령 내부에 있든 \section{...}
(내 설명에서 제안한 대로) 명령 바로 뒤에 있든(작동할 것으로 예상되는 대로) 레이블에 적절하게 액세스할 수 있습니다 .
\documentclass[11pt,a4paper]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[margin=1in]{geometry}
\usepackage{etoolbox}
\newcounter{secnumber}
\pretocmd{\section}{\refstepcounter{secnumber}}{}{}
\renewcommand\sectionstyle[1]{{%
\sectionfont
\textcolor{color1}{\thesecnumber.\quad#1}%
}}
\firstname{First Name}
\familyname{Last Name}
\begin{document}
\makecvtitle
\section{A Section}
\label{sec.one}
Text goes here
\section{Another Section}
\label{sec.two}
Text goes here
\section{Yet Another Section}
\label{sec.three}
Recall in section \ref{sec.one} that we mentioned and in section \ref{sec.two} ... and in section \ref{sec.three} we see
\end{document}