![Sistema Genealógico](https://rvso.com/image/328817/Sistema%20Geneal%C3%B3gico.png)
Estou escrevendo uma história familiar e quero fazer algo assim: para cada pessoa tenho um capítulo, e cada pessoa é identificada por um código único.
Por exemplo algo assim:
\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.
que produzem isso:
John Doe
John Doe nasceu em 1900, lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
Em outra página posso escrever isto:
\personChapter{Jennifer Doe}{23}
Jennifer Doe, born in 1920, is the daughter of \person{1}.
que produzem isso:
Jennifer Doe
Jennifer Doe, nascida em 1920, é filha deJohn Doe¹.
¹ Veja John Doe na página 46.
no qualJohn Doeé um link para a página John Doe (neste exemplo, página 46).
Se eu quiser posso adicionar apenas o link ou apenas a nota de rodapé:
Jennifer Doe, born in 1920, is the daughter of \personLink{1}.
Jennifer Doe, born in 1920, is the daughter of \personFoot{1}.
Também posso especificar outro nome, por exemplo este:
John Doe's \person{23}[daughter] is dead in 1990.
produza isto:
John Doefilha¹ morreu em 1990.
¹ Veja Jennifer Doe na página 125.
no qualfilhaé um link para a página de Jennifer Doe.
Além disso, as pessoas podem ter vários códigos, por exemplo:
\personChapter{Jennifer Doe}{23}[JenniferDoe1920][JD20]
Então posso produzir um índice com todas as pessoas. Para cada pessoa no índice, está vinculada a página principal dessa pessoa:
\printPeopleIndex
Ou, com outro comando, são vinculadas todas as páginas em que são citadas:
\printPeopleAllRef
Algo assim é possível?
Eu escrevi esses comandos que fazem parcialmente o que escrevi acima.
\newcommand{\personChapter}[2]
{
\chapter{#1}
\label{ch:#2}
}
\newcommand{\person}[1]
{
\nameref{ch:#1}
\footnote{See \nameref{ch:#1} on page \pageref{ch:#1} .}
}
Responder1
EDITADO para usar links quentes. Ele utiliza o arquivo aux para salvar as informações da rotulagem, para que possa fazer referência direta e reversa, conforme mostrado neste MWE.
Eu implementei \person
usando um link de nota de rodapé e \personLink
implementando um link direto. EDITADO para implementação \personFoot
que fornece uma nota de rodapé simples sem link para outra página.
O \textheight
é reduzido neste MWE para melhor mostrar o resultado.
\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}
Nota: a \protected@iwrite
macro veio da resposta do egreg emEscrevendo \\ em um arquivo.