系図システム

系図システム

私は家族の歴史を書いています。次のようなことをしたいと思っています。つまり、各人物に章があり、各人物は固有のコードによって識別されるのです。

たとえば次のようになります:

\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}.

これは次のものを生成します:

ジェニファー・ドウ

ジェニファー・ドウは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.

これを生成します:

ジョン・ドゥの¹ は 1990 年に死亡しました。


¹ 125 ページの 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の回答から引用したものです。ファイルへの書き込み

関連情報