%3F.png)
내 문서 구조는 기본적으로 다른 작은 문서의 모음입니다. 나는 내려가지 않기로 결정했다xr-하이퍼결국 요구 사항은 단일 파일이기 때문입니다. 그래서 대신 하위 문서가 포함된 하나의 큰 LaTeX 문서를 만들기로 결정했습니다.서적, 예:
\documentclass{memoir}
\renewcommand*{\thebook}{\Alph{book}} % "Book A", "Book B", etc.
\begin{document}
\book{maindoc}
\chapter{maindoc first chapter}
\label{chap:maindoc-first}
\chapter{maindoc second chapter}
\label{chap:maindoc-second}
\book{extradoc}
\setcounter{chapter}{0} % reset chapter counter with each book
\chapter{extradoc first chapter}
\label{chap:extradoc-first}
\chapter{extradoc second chapter}
\label{chap:extradoc-second}
As shown in \ref{chap:maindoc-first}, and further research in \ref{chap:extradoc-first} ...
\book{anotherdoc}
\setcounter{chapter}{0}
\chapter{anotherdoc chapter}
\end{document}
이제 As shown in \ref{chap:maindoc-first}
해당 장이 현재 부분의 범위에 있는 것처럼 렌더링됩니다. 내가 성취하고 싶은 것은 다음과 같습니다.
- Maindoc의 1장과 1장에서 볼 수 있듯이...
- 1장(maindoc)과 1장에 나와 있듯이...
- (1, maindoc)과 (1)에서 볼 수 있듯이...
- A-1과 1에서 보는 바와 같이...
그러나 대부분의 참고 문헌은 문서 자체 내에 있으므로 접두사를 붙이고 싶지 않습니다.모두에서와 같이 참조의이 Q&A.
이 작업을 어떻게 수행할 수 있나요? 참조 범위를 결정하고 조건부로 접두사를 포함하는 방법이 있습니까?
궁극적으로 정리, 그림, 표 등에 대한 참조에도 동일한 작업을 수행하고 싶습니다.
답변1
을 사용하고 있으므로 memoir
수업에서 제공하는 상호 참조 기능을 활용해야 합니다. 이 내용은 16장에서 다룹니다.사용자 매뉴얼.
memoir
그러나 형식 지정에 대한 상당히 명확한 아이디어가 있으므로 항상 이러한 아이디어 이상의 유연성을 제공하지는 않습니다. 이 경우 문서의 다른 부분에 대한 상호 참조는 대문자로 표시되어야 한다고 생각합니다. 이를 방지하려면 대안을 제공해야 합니다.
다음은 에서 제공하는 버전을 기반으로 합니다 memoir
.
\aref% based on \Aref
\bref% \Bref
\cref% \Cref
\sref% \Sref
소문자 이름은 다음과 같이 제공됩니다.
\lcbookrefname% based on \bookrefname
\lcchapterrefname% \chapterrefname
\lcsectionrefname% identical to \sectionrefname
\lcappendixrefname% based on \appendixrefname
\titleref
이를 통해 에서 제공하는 명령 과 결합할 때 원하는 대로 참조를 설정할 수 있습니다 memoir
.
이를 자동화하기 위해 \chapref{}
나열된 첫 번째 가능성에 따라 형식화된 참조를 생성하는 명령이 제공됩니다. 유사한 방식으로 다른 명령을 생성하여 다른 형식을 얻을 수 있습니다.
메모:나는 내가 명령을 코딩한 방식이 \chapref
적어도 최선의 방법은 아닐 수도 있다고 생각합니다.주의사항
\documentclass{memoir}
\renewcommand*{\thebook}{\Alph{book}} % "Book A", "Book B", etc.
\newcommand*{\aref}[1]{\lcappendixrefname\ref{#1}}
\newcommand*{\bref}[1]{\lcbookrefname\ref{#1}}
\newcommand*{\cref}[1]{\lcchapterrefname\ref{#1}}
\newcommand*{\sref}[1]{\lcsectionrefname\ref{#1}}
\newcommand*{\lcbookrefname}{book~}
\newcommand*{\lcchapterrefname}{chapter~}
\newcommand*{\lcsectionrefname}{\S}
\newcommand*{\lcappendixrefname}{appendix~}
\makeatletter
\def\chapref@book#1:#2-#3\@nil{#2}
\newcommand*{\chapref}[1]{%
\edef\tempa{\expandafter\chapref@book#1\@nil}%
\edef\tempb{\ref{book:\tempa}}%
\edef\tempc{\thebook}%
\ifx\tempb\tempc
\cref{#1}%
\else
\cref{#1} of the \titleref{book:\tempa}%
\fi}
\makeatother
\begin{document}
\book{maindoc}
\label{book:maindoc}
\chapter{maindoc first chapter}
\label{chap:maindoc-first}
\chapter{maindoc second chapter}
\label{chap:maindoc-second}
\book{extradoc}
\label{book:extradoc}
\setcounter{chapter}{0} % reset chapter counter with each book
\chapter{extradoc first chapter}
\label{chap:extradoc-first}
\chapter{extradoc second chapter}
\label{chap:extradoc-second}
Manually using the facilities of the class:
As shown in \cref{chap:maindoc-first} of the \titleref{book:maindoc}, and further research in \cref{chap:extradoc-first} ...
\noindent Or using the custom command:
As shown in \chapref{chap:maindoc-first}, and further research in \chapref{chap:extradoc-first} \dots
\book{anotherdoc}
\setcounter{chapter}{0}
\chapter{anotherdoc chapter}
\end{document}