제가 생각하고 싶은 것은 간단한 질문입니다.
다음과 같은 tex 코드가 있습니다.
\begin{description}%[style=nextline]
\item [Category\label{desc:category}] blablabla
\item [Profile\label{desc:profile}] blabla (\nameref{desc:category}) blabla.
\end{description}
결과는 다음과 같습니다.
범주블라블라블라
프로필blabla('공백 묶음' 카테고리) blabla.
내가 만든 카테고리 참조 뒤에 왜 이런 공백이 생기나요?
답변1
보고 중인 문제를 재현하려면 (또는 ) 패키지 enumitem
외에 패키지를 로드해야 하는 것으로 나타났습니다 . 예를 들어, 다음 MWEhyperref
nameref
\documentclass{article}
\usepackage{enumitem}
\usepackage[colorlinks]{hyperref} % or: \usepackage{nameref}
\begin{document}
\begin{description}
\item[Category\label{desc:category}] blablabla
\item[Profile\label{desc:profile}] blabla
(\nameref{desc:category}) blabla
\end{description}
\end{document}
다음 출력을 생성합니다.
enumitem
간단히 말해서, 와 패키지 사이에 다소 심각하고 불행한 충돌이 발생한 것 같습니다 hyperref
. (크리스티안 후퍼의 답변저보다 몇 분 먼저 게시된 , 갈등 갈등의 성격에 대한 더 심층적인 진단을 제공합니다.) 흥미롭게도 질의에 대한 세 가지 답변은LaTeX의 설명 목록 항목 참조 이름간격 문제를 해결하지 못하는 것 같습니다.
enumitem
패키지를 사용하는 대신낱낱이 세다패키지. 패키지만큼 많은 종소리와 휘파람을 제공하지 않습니다 enumitem
. 그러나 형식 요구 사항(지금까지 정확히 0으로 공개한 내용)에 따라 패키지는 enumerate
실제로 필요한 모든 기능을 제공할 수 있습니다.
그러나 만약 당신이 단순히~ 해야 하다패키지 를 사용해보세요 enumitem
.~ 아니다환경 내부에서는 basic-LaTeX 메커니즘을 사용합니다 \label
. 대신, 패키지 의 보다 일반적인 메커니즘을 사용 하십시오 .\ref
description
\hypertarget
\hyperlink
hyperref
\documentclass{article}
\usepackage{enumerate}
\usepackage[colorlinks]{hyperref}
\begin{document}
\begin{description}
\item[\hypertarget{desc:category}{Category}] blablabla
\item[\hypertarget{desc:profile}{Profile}] blabla
(\hyperlink{desc:category}{Category}) blabla
\end{description}
\end{document}
답변2
OP가 다음을 사용하고 있는 것 같습니다. enumitem
(힌트: style=nextline
)
enumitem
\hfil
매크로 에 a를 추가 \descriptionlabel
하면 레이블이 이 되고 Category\hfil
오른쪽에 큰 공간이 남게 됩니다.
표준 클래스(더 나은: LaTeX 코어)의 환경 description
에는 이것이 바람직하지 않은 기능이 없습니다.
아이디어는 에 대해 저장되는 이름인 매크로 \let\hfil\relax
에 있습니다 .\@currentlabelname
\nameref
\documentclass{article}
\usepackage{enumitem} % Add easy custom list support
\usepackage{hyperref} % Add ref support
%\setlength\parindent{0pt} % Globally set indentation for new paragraphs
\setlist[description]{labelwidth=0pt,leftmargin=30pt,itemindent=\dimexpr-20pt-\labelsep\relax} % Global Setup Description List
\makeatletter % Redefinition of Description List Items source: http://tex.stackexchange.com/a/1248/13552
\let\orgdescriptionlabel\descriptionlabel
\renewcommand*{\descriptionlabel}[1]{%
\let\orglabel\label
\let\label\@gobble
\phantomsection
\protected@edef\@currentlabel{#1}%
\edef\@currentlabelname{\let\hfil\relax #1}%
\let\label\orglabel
\orgdescriptionlabel{#1}%
}
\makeatother
\begin{document}
\begin{description}
\item [Category\label{desc:category}] blablabla
\item [Profile\label{desc:profile}] blabla (\nameref{desc:category}) blabla.
\end{description}
\end{document}
답변3
파일 을 보시면 .aux
아시겠지만
\newlabel{desc:category}{{}{1}{\enit@align {\enit@format {Category\label {desc:category}}}}{Doc-Start}{}}
\newlabel{desc:profile}{{}{1}{\enit@align {\enit@format {Profile\label {desc:profile}}}}{Doc-Start}{}}
\enit@align
우리는 and 를 제거하고 싶습니다 \enit@format
. 옵션 gettitlestring
을 사용하여 패키지를 로드 expand
하고 원하지 않는 두 명령이 단순히 인수를 전달하도록 하여 비활성화 하면 됩니다 . 이 재정의는 nameref
매크로가 제목을 수집하는 동안에만 일시적입니다 .
\documentclass{article}
\usepackage{enumitem} % Add easy custom list support
\usepackage[expand]{gettitlestring}
\usepackage{hyperref} % Add ref support
\setlist[description]{% Global Setup Description List
labelwidth=0pt,
leftmargin=30pt,
itemindent=\dimexpr-20pt-\labelsep\relax
}
\makeatletter
\GetTitleStringDisableCommands{%
\let\enit@align\@firstofone
\let\enit@format\@firstofone
}
\makeatother
\begin{document}
\begin{description}
\item [Category\label{desc:category}] blablabla
\item [Profile\label{desc:profile}] blabla (\nameref{desc:category}) blabla.
\end{description}
\end{document}
이제 .aux
파일에는
\newlabel{desc:category}{{}{1}{Category}{Doc-Start}{}}
\newlabel{desc:profile}{{}{1}{Profile}{Doc-Start}{}}
출력은 예상대로입니다.