상호 참조가 제대로 고정되지 않았습니다.

상호 참조가 제대로 고정되지 않았습니다.

다음과 같이 작성된 코드가 있습니다.

\documentclass[8pt,a4paper,dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,hmargin=2cm,vmargin={2cm,2.5cm}]{geometry}
\usepackage[colorlinks=false]{hyperref}
\hypersetup{
    pdftitle={...},
    pdfauthor={...},
    pdfsubject={...},
    pdfkeywords={...},
}
\usepackage{enumitem}
\usepackage{chngcntr}
\usepackage{cleveref}
\usepackage{etoolbox,cancel,mathtools,physics}

\counterwithin*{equation}{section}
\counterwithin*{equation}{subsection}
\counterwithin*{equation}{enumi}

\newif\ifinenumerate
\AtBeginEnvironment{enumerate}{\inenumeratetrue}

\makeatletter
\renewcommand\theequation{%
  \ifnum\value{subsection}>0 \thesubsection.\else
  \ifnum\value{section}>0 \thesection.\fi\fi
  \ifinenumerate \theenumi\fi
  \arabic{equation}}
\makeatother

\begin{document}
\section{Test 1}
\subsection{Test 1.1}
\begin{enumerate}[label=\alph*.]
\item item a
    \begin{itemize}
        \item item a case 1         
        \begin{equation*}
        a = b
        \end{equation*}             
        \begin{itemize}
        \item item a case 1 subcase 1       
        \begin{equation}
        a = b \label{eq:Eq1.1.a.1}
        \end{equation}
        \end{itemize}
    \end{itemize}
    \begin{equation}
    a = b \label{eq:Eq1.1.a.2}
    \end{equation}
\end{enumerate}
\subsection{Test 1.2}
\begin{equation} 
\underbrace{
            \cancel{\pdv{t}\delta n}
            }_{
               \mathclap{\substack{\text{stationary} \\ \text{case}}}
              } 
              + 
\underbrace{
            \cancel{\mu^*\va{E}\grad_{\va{r}}{\var n}}
            }_{
               \substack{\mu^* = 0 \\ \text{if} \\ n_0 = p_0 = n_i}
              } 
              - 
D^*\laplacian_{\va{r}}\delta n 
              - 
\underbrace{
            \frac{\delta n}{\tau^*}
            }_{
               \mathclap{\substack{\text{it vanishes for} \\ \text{lengths less than}\ L}}
              } 
              - 
g_L = 0 \label{eq:AmbipEq}
\end{equation}
\subsection{Test 1.3}
Cross reference to \eqref{eq:AmbipEq} which is not properly anchored 
\end{document}

그리고 왜 제대로 고정되지 않았는지 알고 싶습니다. eq:AmbipEq아마도 그게 원인이거나 \mathclap사용 때문일까요 \substack? 매우 감사합니다!

답변1

귀하의 예를 테스트할 때 다음 줄을 얻었습니다.

\newlabel{eq:AmbipEq}{{1.2.1}{1}{Test 1.2}{equation.1.1}{}}

.aux 파일에.

즉, 이름이 인 앵커에 연결되는 동안 레이블을 참조하면 eq:AmbipEq번호가 "인쇄"됩니다 .1.2.1equation.1.1

.log 파일에는 몇 가지 경고가 포함되어 있습니다. 그 중 하나는 다음과 같습니다

pdfTeX warning (ext4): destination with the same identifier (name{equation.1.1}) has been already used, duplicate ignored

이는 어떤 이유로 이름이 인 앵커를 배치하려는 시도가 두 번 있었음을 의미합니다 equation.1.1.
모든 하이퍼링크는 해당 앵커를 처음 배치하려는 시도가 발생한 .TeX-input-file/source-file의 위치에 해당하는 출력 파일/.pdf 파일의 해당 위치로 연결됩니다.

그 이유는 무엇입니까?:

매크로는 \theequation방정식 카운터 값을 "인쇄"하는 방법을 지정하는 데 사용됩니다.

hyperref-package를 사용할 때 값을 인쇄하는 것 외에 또 다른 문제가 있습니다.

번호가 매겨진 "루브화 항목"의 새로운 인스턴스가 출력 파일(pdf 파일)에 배치되는 경우, 즉 번호가 매겨진 섹션 제목, 번호가 매겨진 그림의 캡션, 번호가 매겨진 표의 캡션, 또는 수식/방정식의 수에 따라 해당 카운터의 값이 인쇄되고 하이퍼링크용 앵커가 배치됩니다. 해당 앵커에는 전체 문서 내에서 고유한 이름이 필요합니다.

매크로는 \theHequationhyperref-package가 사용 중일 때 방정식 번호와 관련된 앵커 이름이 자동으로 생성되는 방식을 지정하는 데 사용됩니다.

매크로는 \theHequation앵커 이름의 고유성을 보장하는 방식으로 지정되어야 합니다.

재정의/변경할 때 앵커 이름의 고유성을 보장하기 위해 \theequation조정/재정의도 필요할 수 있습니다 .\theHequation

그러므로 나는 배치하는 것과 병행하는 것을 제안합니다

\renewcommand\theequation{%
  \ifnum\value{subsection}>0 \thesubsection.\else
  \ifnum\value{section}>0 \thesection.\fi\fi
  \ifinenumerate \csname theenum\romannumeral\the\@enumdepth\endcsname\fi
  \arabic{equation}%
}

같은 것을 배치

\AtBeginDocument{%
  \renewcommand\theHequation{%
    \ifnum\value{subsection}>0 \theHsubsection.\else
    \ifnum\value{section}>0 \theHsection.\fi\fi
    \ifinenumerate \csname theHenum\romannumeral\the\@enumdepth\endcsname.\fi
    \arabic{equation}%
  }%
}

문서의 서문에 넣습니다.

(두 코드 조각 모두 @문자(→ \makeatletter..\makeatother)로 만들어지는 것으로 가정합니다.)

이 작업을 수행할 때 .aux 파일에 항목이 들어갑니다.

\newlabel{eq:AmbipEq}{{1.2.1}{1}{Test 1.2}{equation.1.2.1}{}} 

즉, 레이블을 참조하면 이름이 인 앵커에 연결되는 동안 eq:AmbipEq번호가 "인쇄"됩니다 .1.2.1equation.1.2.1

동일한 식별자를 가진 대상에 대한 해당 pdfTeX 경고는 .log 파일 내에서 발생하지 않습니다.

\documentclass[8pt,a4paper,dvipsnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,hmargin=2cm,vmargin={2cm,2.5cm}]{geometry}
\usepackage[colorlinks=false]{hyperref}
\hypersetup{
    pdftitle={...},
    pdfauthor={...},
    pdfsubject={...},
    pdfkeywords={...},
}
\usepackage{enumitem}
\usepackage{chngcntr}
\usepackage{cleveref}
\usepackage{etoolbox,cancel,mathtools,physics}

\counterwithin*{equation}{section}
\counterwithin*{equation}{subsection}
\counterwithin*{equation}{enumi}

\newif\ifinenumerate
\AtBeginEnvironment{enumerate}{\inenumeratetrue}

\newcommand{\prr}{\\[0.5cm]} %

\makeatletter
\renewcommand\theequation{%
  \ifnum\value{subsection}>0 \thesubsection.\else
  \ifnum\value{section}>0 \thesection.\fi\fi
  \ifinenumerate \csname theenum\romannumeral\the\@enumdepth\endcsname\fi
  \arabic{equation}%
}
\AtBeginDocument{%
  \renewcommand\theHequation{%
    \ifnum\value{subsection}>0 \theHsubsection.\else
    \ifnum\value{section}>0 \theHsection.\fi\fi
    \ifinenumerate \csname theHenum\romannumeral\the\@enumdepth\endcsname.\fi
    \arabic{equation}%
  }%
}
\makeatother

\begin{document}
\section{Test 1}
\subsection{Test 1.1}
\begin{enumerate}[label=\alph*.]
\item item a
    \begin{itemize}
        \item item a case 1
        \begin{equation*}
        a = b
        \end{equation*}
        \begin{itemize}
        \item item a case 1 subcase 1
        \begin{equation}
        a = b \label{eq:Eq1.1.a.1}
        \end{equation}
        \end{itemize}
    \end{itemize}
    \begin{equation}
    a = b \label{eq:Eq1.1.a.2}
    \end{equation}
\end{enumerate}
\subsection{Test 1.2}
\begin{equation}
\underbrace{
            \cancel{\pdv{t}\delta n}
            }_{
               \mathclap{\substack{\text{stationary} \\ \text{case}}}
              }
              +
\underbrace{
            \cancel{\mu^*\va{E}\grad_{\va{r}}{\var n}}
            }_{
               \substack{\mu^* = 0 \\ \text{if} \\ n_0 = p_0 = n_i}
              }
              -
D^*\laplacian_{\va{r}}\delta n
              -
\underbrace{
            \frac{\delta n}{\tau^*}
            }_{
               \mathclap{\substack{\text{it vanishes for} \\ \text{lengths less than}\ L}}
              }
              -
g_L = 0 \label{eq:AmbipEq}
\end{equation}
\begin{align}
n &= N_C e^{\left(\frac{E_F-E_C}{K_B T}\right)} \nonumber
\prr
\frac{N_D^+}{N_D^0} &= \frac{1}{g_D}e^{\left(\frac{E_D-E_F}{K_BT}\right)} \label{eq:EqToLabeling}
\end{align}
\subsection{Test 1.3}
Cross reference to \eqref{eq:AmbipEq} which is hopefully properly anchored

Cross reference to \eqref{eq:EqToLabeling} which is hopefully properly anchored as well.
\end{document}

그런데:

나는 (La)TeX의 읽기 장치와 입력에서 공백 문자를 만날 때 (La)TeX가 공백 토큰을 생성하는 상황(출력 파일에서 수평 공백 생성)에 대해 배우는 것이 중요하다고 생각합니다. 파일.
예를 들어, 입력 파일에서 여는 중괄호 문자 뒤 또는 닫는 중괄호 문자 뒤의 공백 문자는 출력 파일의 수평 공백으로 이어지는 공백 토큰을 생성합니다( La)TeX는 수직 모드 중 하나가 아닙니다.
예를 들어 여는 중괄호 문자 뒤나 닫는 중괄호 문자 뒤의 줄 바꿈도 공백 토큰을 생성합니다. 그 이유는 입력을 읽을 때 (La)TeX가 각 줄 끝에 공백 문자를 삽입하기 때문입니다. 이는 정수 매개변수와 관련이 있습니다 \endlinechar.

출력 파일/pdf 파일 내에서 원치 않는 수평 공간을 피하기 위해 %줄 끝에서 여는 중괄호 문자 뒤와 줄 끝에서 닫는 중괄호 문자 뒤에 comment-char를 사용하는 것을 고려하십시오 {%. }%

\documentclass{article}

\newcommand\TeXA{\TeX{
}\TeX}

\newcommand\TeXB{\TeX{}
\TeX}

\newcommand\TeXC{\TeX{%
}\TeX}

\newcommand\TeXD{\TeX{}%
\TeX}

\begin{document}

\noindent There are subtle differences in spacing:

\noindent \TeXA

\noindent \TeXB

\noindent \TeXC

\noindent \TeXD

\end{document}

관련 정보