语境:由于我的参考书目由 200 多个条目组成,我想在每个新字母处添加边注,以便按字母顺序拆分参考书目。(即,在作者姓名以 B 开头的第一个条目旁边的边距中打印“B”,等等。)
我的文档使用 KOMA 脚本类,并且我使用biblatex
。
为此,我几乎成功地适应了Ulrike Fischer 的解决方案提议如何按字母顺序划分参考书目?。
问题:我使用 KOMA 脚本\marginline{<text>}
在页边距中打印文本。但是,在段落开头使用此命令会创建一个页边距注释...,该注释与上一段的最后一行垂直对齐。因此,我需要使用 来\raisebox{-\baselineskip}{<text>}
正确对齐页边距注释,如下所示。
然而,当我在参考书目中做同样的事情时,边注却被“去凸起”太多了:
问题:降低边注的正确长度是多少? (为什么它与不同\baselineskip
?)
附加问题:当前的边注是与参考书目字体大小相同的字母。我可能想增加它的大小。那么问题是:如何将边注的顶部与相关书目条目的顶部垂直对齐?
移动网络
\documentclass[twoside]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[%
backend=biber, %use biber as processing program
bibstyle=authoryear, %how is LoR organized
sorting=nyt, %how are entries sorted in the LoR
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
%% Adaptation of Ulrike Fischer's solution https://tex.stackexchange.com/a/150176/64454
\makeatletter
\bibinitsep=1sp %to trigger blx@initsep
\def\blx@initsep{%
\blx@imc@iffieldundef{sortinit}
{}
{%
\ifnum\c@instcount>\@ne
\blx@imc@iffieldequals{sortinit}\blx@previnit
{}
{\marginline{\raisebox{-\baselineskip}{\sffamily\bfseries\printfield{sortinit}}}}
\fi
\global\let\blx@previnit\abx@field@sortinit%
}%
}
\makeatother
%% End of solution
\begin{filecontents}{\jobname.bib}
@InBook{Azerty,
author = {Paul Azerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
Url = {http://dx.doi.org/10.007/1234567890987654321},
year = 2010}
@Book{Aqsdfgh,
author = {Paul Aqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
year = 2010}
@Article{Awxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Awxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Url = {http://dx.doi.org/10.007/1234567890987654321},
Volume = {17},
}
@InBook{Bzerty,
author = {Paul Bzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@Book{Bqsdfgh,
author = {Paul Bqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
Url = {http://dx.doi.org/10.007/1234567890987654321},
year = 2010}
@Article{Bwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Bwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Volume = {17},
}
@InBook{Dzerty,
author = {Paul Dzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@Book{Dqsdfgh,
author = {Paul Dqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
year = 2010}
@Article{Dwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Dwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Volume = {17},
}
@InBook{Kzerty,
author = {Paul Kzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@Book{Zqsdfgh,
author = {Paul Dqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
year = 2010}
@Article{Zwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Zwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Volume = {17},
}
\end{filecontents}
\usepackage[francais]{babel}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\marginline{Too high}
\lipsum[2]
\marginline{\raisebox{-\baselineskip}{Good}}
\lipsum[3]
\newpage
\nocite*
\printbibliography
\end{document}
答案1
不要降低条目,而是在其前面\marginline
添加,以确保段落在命令开始执行其工作时开始:\leavevmode
\makeatletter
\bibinitsep=1sp %to trigger blx@initsep
\def\blx@initsep{%
\blx@imc@iffieldundef{sortinit}
{}
{%
\ifnum\c@instcount>\@ne
\blx@imc@iffieldequals{sortinit}\blx@previnit
{}
{\leavevmode\marginline{\sffamily\bfseries\printfield{sortinit}}}%
\fi
\global\let\blx@previnit\abx@field@sortinit
}%
}
\makeatother
和
\lipsum[1]
\leavevmode\marginline{Too high}
\lipsum[2]
\leavevmode\marginline{Good}
\lipsum[3]
答案2
迭代克莱门斯的回答,这是“奖励问题”的解决方案。不是将书目条目和边注基线对齐(即克莱门斯的答案中所做的),顶端边注现在与顶端书目条目的大写字母。 (更准确地说,书目条目的大写字母与边注的大写字母顶部对齐。)
这尤其允许使用比书目条目字体更大(或更小)的首字母。
“技巧”是使用raisebox
将首字母向下放置,使其与书目条目的基线对齐,然后将其降低到书目条目大写字母的高度。
(唯一可能出现的“问题”是首字母大于页面底部的条目 - 参见 MWE 中的“L” - 但在我看来,这仍然是可以接受的)
\documentclass[twoside, a5, 12pt]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[%
backend=biber, %use biber as processing program
bibstyle=authoryear, %how is LoR organized
sorting=nyt, %how are entries sorted in the LoR
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
%% Define font for bibliography and marginnote + some length calculation
\usepackage{calc}
\newcommand{\mybibliographyfont}{\normalfont}
\newcommand{\mybibliographymagrinnotefont}{\Huge\sffamily\bfseries}
\newlength{\normallineheight}
\setlength{\normallineheight}{\heightof{\mybibliographyfont M}}
\newlength{\marginnoteheight}
\setlength{\marginnoteheight}{\heightof{\mybibliographymagrinnotefont M}}
%% Adaptation of Ulrike Fischer's solution https://tex.stackexchange.com/a/150176/64454
\makeatletter
\bibinitsep=1sp %to trigger blx@initsep
\def\blx@initsep{%
\blx@imc@iffieldundef{sortinit}
{}
{%
\ifnum\c@instcount>\@ne
\blx@imc@iffieldequals{sortinit}\blx@previnit
{}
{\leavevmode\marginline{\raisebox{\dimexpr\normallineheight-\marginnoteheight\relax}{\mybibliographymagrinnotefont\printfield{sortinit}}}}% The objective is here to top-align capital letters of bib entry and the margin note
\fi
\global\let\blx@previnit\abx@field@sortinit%
}%
}
\makeatother
%% End of solution
\begin{filecontents}{\jobname.bib}
@InBook{Azerty,
author = {Paul Azerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
Url = {http://dx.doi.org/10.007/1234567890987654321},
year = 2010}
@Book{Aqsdfgh,
author = {Paul Aqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
year = 2010}
@Article{Awxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Awxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Url = {http://dx.doi.org/10.007/1234567890987654321},
Volume = {17},
}
@InBook{Bzerty,
author = {Paul Bzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@Book{Bqsdfgh,
author = {Paul Bqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
Url = {http://dx.doi.org/10.007/1234567890987654321},
year = 2010}
@Article{Bwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Bwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Volume = {17},
}
@InBook{Dzerty,
author = {Paul Dzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@Book{Dqsdfgh,
author = {Paul Dqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
year = 2010}
@Article{Dwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Dwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Volume = {17},
}
@InBook{Kzerty,
author = {Paul Kzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@InBook{Kzerty2,
author = {Paul Kzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@InBook{Kzerty3,
author = {Paul Kzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@InBook{Kzerty4,
author = {Paul Kzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@InBook{Kzerty5,
author = {Paul Kzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
year = 2010}
@InBook{Lzerty,
author = {Paul Lzerty and Doe, John and Musterman, Erika},
title = {Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
chapter = {Cras bibendum leo mauris, a ornare dolor rutrum egestas.},
publisher = {Donec consequat},
Url = {http://dx.doi.org/10.007/1234567890987654321},
year = 2010}
@Book{Lqsdfgh,
author = {Paul Lqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
year = 2010}
@Article{Lwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Lwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Url = {http://dx.doi.org/10.007/1234567890987654321},
Volume = {17},
}
@Book{Zqsdfgh,
author = {Paul Dqsdfgh and Musterman, John and Doe, Erika},
title = {Mauris bibendum diam lorem},
publisher = {Aliquam},
year = 2010}
@Article{Zwxcvb,
Title = {In euismod est eget urna euismod, cursus tincidunt odio dignissim.},
Author = {Paul Zwxcvb and Musterdoe, Jerika and Dann, Eron},
Journal = {Maecenas pharetra},
Year = {2010},
Number = {13},
Pages = {13--17},
Publisher = {Pellentesque},
Volume = {17},
}
\end{filecontents}
\usepackage[francais]{babel}
\usepackage{lipsum}
\begin{document}
\nocite*
\mybibliographyfont
\printbibliography
\end{document}