当我尝试将结婚日期添加到用户指南中的一个基本示例中时,我得到一条与照片重叠的水平线:
这是我的代码:
\documentclass{article}
\usepackage{genealogytree}
\usepackage{tcolorbox}
\begin{document}
\begin{genealogypicture}[
processing=database,
database format=medium marriage below,
node size=2.4cm,
level size=3.5cm,
level distance=6mm,
%...
list separators hang,
name font=\bfseries,
surn code={\textcolor{red!50!black}{#1}},
place text={\newline}{},
date format=d/mon/yyyy,
%...
tcbset={male/.style={colframe=blue,colback=blue!5},
female/.style={colframe=red,colback=red!5}},
box={fit basedim=7pt,boxsep=2pt,segmentation style=solid,
halign=left,before upper=\parskip1pt,
\gtrDBsex,drop fuzzy shadow,
if image defined={add to width=25mm,right=25mm,
underlay={\begin{tcbclipinterior}\path[fill overzoom DBimage]
([xshift=-24mm]interior.south east) rectangle (interior.north east);
\end{tcbclipinterior}},
}{},
},
]
sandclock
{
child{
g[id=GauxCarl1777]{
male,
name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
birth={1777-04-30}{Braunschweig (Niedersachsen)},
marriage={1800-01-01}{}, %<== my modification to the guide's example
death={1855-02-23}{G\"ottingen (Niedersachsen)},
profession={Mathematiker, Astronom, Geod\"at und Physiker},
image={Carl_Friedrich_Gauss.jpg},
}
p[id=GauxCarl1777]{
female,
name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
birth={1777-04-30}{Braunschweig (Niedersachsen)},
marriage={1800-01-01}{}, %<== my modification to the guide's example
death={1855-02-23}{G\"ottingen (Niedersachsen)},
profession={Mathematiker, Astronom, Geod\"at und Physiker},
image={Carl_Friedrich_Gauss.jpg},
}
}
}
\end{genealogypicture}
\end{document}
有人知道如何防止这种情况吗?
答案1
对此有多种可能的解决方案。最简单的方法是更改为不画线的数据库格式,例如medium
。在这种情况下,婚姻信息会打印在出生和死亡之间。
梅威瑟:
\documentclass{article}
\usepackage{genealogytree}
\usepackage{tcolorbox}
\begin{document}
\begin{genealogypicture}[
processing=database,
database format=medium,
box={fit basedim=7pt,boxsep=2pt,segmentation style=solid,
halign=left,before upper=\parskip1pt,
\gtrDBsex,drop fuzzy shadow,
if image defined={add to width=25mm,right=25mm,
underlay={\begin{tcbclipinterior}\path[fill overzoom image=\gtrDBimage]
([xshift=-24mm]interior.south east) rectangle (interior.north east);
\end{tcbclipinterior}},
}{},
},
]
sandclock{
child{
g[id=GauxCarl1777]{
male,name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
birth={1777-04-30}{Braunschweig (Niedersachsen)},
marriage={1800-01-01}{},
death={1855-02-23}{G\"ottingen (Niedersachsen)},
profession={Mathematiker, Astronom, Geod\"at und Physiker},
image={Carl_Friedrich_Gauss.jpg},
}
}
child{
g[id=GauxCarl1777]{
female,name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
birth={1777-04-30}{Braunschweig (Niedersachsen)},
marriage={1800-01-01}{},
death={1855-02-23}{G\"ottingen (Niedersachsen)},
profession={Mathematiker, Astronom, Geod\"at und Physiker},
}
}
}
\end{genealogypicture}
\end{document}
结果:
第二种可能性是更改的定义medium marriage below
以删除该行。定义列在文件中gtrcore.node.code.tex
,加载后,可以通过将修改后的代码添加到您自己的文档中来重新定义它们genealogytree
。
梅威瑟:
\documentclass{article}
\usepackage{genealogytree}
\usepackage{tcolorbox}
\makeatletter
\gtrDeclareDatabaseFormat{medium marriage below}{}{%
\gtrPrintName%
\begin{gtreventlist}%
\gtr@list@event@birth%
\gtr@list@event@floruit%
\gtr@list@event@death%
\end{gtreventlist}%
\gtr@print@infolist%
\gtr@ifmarriagedefined{%
\begin{gtreventlist}\gtr@list@event@marriage\end{gtreventlist}}{}%
% was: \gtr@ifmarriagedefined{\tcbline\begin{gtreventlist}\gtr@list@event@marriage\end{gtreventlist}}{}%
}
\makeatother
\begin{document}
\begin{genealogypicture}[
processing=database,
database format=medium marriage below,
box={fit basedim=7pt,boxsep=2pt,segmentation style=solid,
halign=left,before upper=\parskip1pt,
\gtrDBsex,drop fuzzy shadow,
if image defined={add to width=25mm,right=25mm,
underlay={\begin{tcbclipinterior}\path[fill overzoom image=\gtrDBimage]
([xshift=-24mm]interior.south east) rectangle (interior.north east);
\end{tcbclipinterior}},
}{},
},
]
sandclock{
child{
g[id=GauxCarl1777]{
male,name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
birth={1777-04-30}{Braunschweig (Niedersachsen)},
marriage={1800-01-01}{},
death={1855-02-23}{G\"ottingen (Niedersachsen)},
profession={Mathematiker, Astronom, Geod\"at und Physiker},
image={Carl_Friedrich_Gauss.jpg},
}
}
child{
g[id=GauxCarl1777]{
female,name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
birth={1777-04-30}{Braunschweig (Niedersachsen)},
marriage={1800-01-01}{},
death={1855-02-23}{G\"ottingen (Niedersachsen)},
profession={Mathematiker, Astronom, Geod\"at und Physiker},
}
}
}
\end{genealogypicture}
\end{document}
结果:
为了稍微扩展这个解决方案,您可以测试是否存在图像,并且只打印没有图像的节点的行,例如,否则打印一点垂直空间。
MWE,仅显示重新定义的相关部分:
\gtr@ifmarriagedefined{%
\ifdefvoid{\gtrDBimage}{\tcbline}{\vspace{2mm}}%
\begin{gtreventlist}\gtr@list@event@marriage\end{gtreventlist}}{}%
结果:
或者在两种情况下都添加\tcbline
,如果有图像,则会使线短 24 毫米:
\gtr@ifmarriagedefined{%
\ifdefvoid{\gtrDBimage}{\tcbline}{%
\tcbline@ {\kvtcb@leftupper +\@totalleftmargin +24mm}}%
\begin{gtreventlist}\gtr@list@event@marriage\end{gtreventlist}}{}%
结果: