我正在使用biblatex-ext
和longtable
排版基于书目的参考文献表。为了更好地概览,我想用规则分隔各个行,并在底部打印粗体规则。出于美观原因,我还重新格式化了重复出现的规则,使它们更细且呈灰色。
不幸的是,行分隔符规则也打印在最后一行之后,就在额外的底部规则之前:
从biblatex-ext
手册中可以看出,没有明显的选项来区分任何行(例如偶数/奇数行)\defbibtabular{⟨name⟩}{⟨begin code⟩}{⟨end code⟩}{⟨row code⟩}
:。
我又怎么能
- 重新排列整个规则格式代码,使其适合环境
biblatex-ext-tabular
或 - 检测该行是否是表中的最后一行(因此省略规则输出)以避免表末尾出现双线?
梅威瑟:
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel,csquotes}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{biblatex-ext-tabular}
\usepackage{longtable,array,booktabs}
\usepackage{xcolor,colortbl}
\defbibtabular{bibtabular}
{\begin{longtable}{@{}lll@{}}
\toprule
\textbf{Author} & \textbf{Title} & \textbf{Year}\\
\midrule[\heavyrulewidth]\endhead%
\arrayrulecolor{black!30}%--prepare color for all midrules
}
{\arrayrulecolor{black}\bottomrule
\end{longtable}}
{\anchorlang{\usebibmacro{author/editor+others}}
& \plainlang{\usebibmacro{title}}
& \plainlang{\printdate}
\\\midrule[0.3pt]}
\begin{filecontents*}{\jobname.bib}
@Book{Miller1832a,
author = {John Miller},
title = {Elementary book},
year = {1832},
}
@inbook{Smith1744a,
author = {Daniel Smith},
booktitle = {Collection of important articles},
title = {Noteworthy Article},
year = {1744},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibtabular
\end{document}
PS: 此 MWE 复制(并修改自)自这里
答案1
一个肮脏的解决办法是添加另一个最后一行(也是空行),但行高为负数,这样粗线bottomrule
就刚好打印在细灰midrule
线上方。这不是一个好的解决方案,但它确实有效:
这是修补后的 MWE(只需运行 2 或 3 次即可获得最终结果):
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel,csquotes}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{biblatex-ext-tabular}
\usepackage{longtable,array,booktabs}
\usepackage{xcolor,colortbl}
\defbibtabular{bibtabular}
{\begin{longtable}{@{}lll@{}}
\toprule
\textbf{Author} & \textbf{Title} & \textbf{Year}\\
\midrule[\heavyrulewidth]\endhead%
\arrayrulecolor{black!30}%--prepare color for all midrules
}
{\\[-0.6cm]\arrayrulecolor{black}\bottomrule
\end{longtable}}
{\anchorlang{\usebibmacro{author/editor+others}}
& \plainlang{\usebibmacro{title}}
& \plainlang{\printdate}
\\\midrule[0.3pt]}
\begin{filecontents*}{\jobname.bib}
@Book{Miller1832a,
author = {John Miller},
title = {Elementary book},
year = {1832},
}
@inbook{Smith1744a,
author = {Daniel Smith},
booktitle = {Collection of important articles},
title = {Noteworthy Article},
year = {1744},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibtabular
\end{document}