계보 시스템

계보 시스템

나는 가족 역사를 쓰고 있는데 다음과 같은 일을 하고 싶습니다. 모든 사람에 대해 장을 갖고 모든 사람은 고유한 코드로 식별됩니다.

예를 들어 다음과 같습니다.

\personChapter{John Doe}{1}

John Doe is born in 1900, lorem ipsum dolor sit amet, consectetur adipisci
elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.

이는 다음을 생성합니다.

존 도우

John Doe는 1900년에 태어났습니다. lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.

다른 페이지에서는 다음과 같이 쓸 수 있습니다.

\personChapter{Jennifer Doe}{23}

Jennifer Doe, born in 1920, is the daughter of \person{1}.

이는 다음을 생성합니다.

제니퍼 도우

제니퍼 도(Jennifer Doe)는 1920년에 태어났습니다.존 도우¹.


¹ 46페이지의 John Doe를 참조하세요.

어느존 도우John Doe 페이지에 대한 링크입니다(이 예에서는 46페이지).

원할 경우 링크만 추가하거나 각주만 추가할 수 있습니다.

Jennifer Doe, born in 1920, is the daughter of \personLink{1}.

Jennifer Doe, born in 1920, is the daughter of \personFoot{1}.

다른 이름을 지정할 수도 있습니다. 예를 들면 다음과 같습니다.

John Doe's \person{23}[daughter] is dead in 1990.

이것을 생산하십시오 :

존 도우의1은 1990년에 사망했습니다.


¹ 125페이지의 Jennifer Doe를 참조하세요.

어느Jennifer Doe 페이지에 대한 링크입니다.

또한 사람들은 다음과 같은 여러 코드를 가질 수 있습니다.

\personChapter{Jennifer Doe}{23}[JenniferDoe1920][JD20]

그러면 모든 사람이 포함된 색인을 생성할 수 있습니다. 색인에 있는 모든 사람에 대해 해당 사람의 기본 페이지가 연결됩니다.

\printPeopleIndex

또는 다른 명령을 사용하면 해당 내용이 인용된 모든 페이지에 연결됩니다.

\printPeopleAllRef

이런 일이 가능합니까?


나는 위에서 쓴 내용을 부분적으로 수행하는 다음 명령을 작성했습니다.

\newcommand{\personChapter}[2]
{
\chapter{#1}
\label{ch:#2}
}

\newcommand{\person}[1]
{
\nameref{ch:#1}
\footnote{See \nameref{ch:#1} on page \pageref{ch:#1} .}
}

답변1

핫링크를 사용하도록 편집되었습니다. 이 MWE에 표시된 것처럼 라벨링 정보를 저장하기 위해 aux 파일을 사용하므로 정방향 및 역방향 참조가 가능합니다.

\person각주 링크를 사용하여 구현하고 , \personLink직접 링크를 구현했습니다. \personFoot다른 페이지에 대한 링크 없이 일반 각주를 제공하도록 구현하도록 편집되었습니다 .

\textheight결과를 더 잘 보여주기 위해 이 MWE에서는 가 축소되었습니다 .

\documentclass{article}
\usepackage{lipsum}
\makeatletter
\long\def \protected@iwrite#1#2#3{%
     \begingroup
     \let\thepage\relax
     #2%
     \let\protect\@unexpandable@protect
     \edef\reserved@a{\immediate\write#1{#3}}%
     \reserved@a
     \endgroup
     \if@nobreak\ifvmode\nobreak\fi\fi
    }
\newcommand\personChapter[2]{\bigskip%
  \protected@iwrite\@auxout{\def\nex{\noexpand\noexpand\noexpand}}{%
    \nex\expandafter\xdef%
    \nex\csname GenLabel#2%
    \nex\endcsname{#1}%
  }%
  \label{Label#2}%
  \noindent\textbf{#1}\smallskip}
\makeatother
\newcommand\person[1]{\csname GenLabel#1\endcsname\footnote{%
  See \csname GenLabel#1\endcsname{} on page \pageref{Label#1}}}
\newcommand\personLink[1]{\csname GenLabel#1\endcsname{} (page \pageref{Label#1})}
\newcommand\personFoot[1]{\csname GenLabel#1\endcsname\footnote{%
  See \csname GenLabel#1\endcsname{} on page \pageref*{Label#1}}}
\parindent 0pt
\textheight 2in
\usepackage{hyperref}

\begin{document}
\personChapter{John Doe}{1}

John Doe is born in 1900, father of \person{23} or, using unlinked footnote,
father of \personFoot{23}, \lipsum[3]

\personChapter{Jennifer Doe}{23}

Jennifer Doe, born in 1920, is the daughter of \person{1} or,
  using no footnote, the daughter of \personLink{1}.
\end{document}

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

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


참고: \protected@iwrite매크로는 egreg의 답변에서 나왔습니다.파일에 \\ 쓰기.

관련 정보