latex中生成表格形式的参考文献表

latex中生成表格形式的参考文献表

1. 引言

一般书籍中的参考文献表从内容上看是文本字符串,从格式上看是由一个一个段落构成的。通常latex中的参考文献表是一个由list环境构成的文本块,内部的每一项是由list环境设置参数确定格式的段落。所谓我们调整文献表的段落格式是:(1) 通过对thebibliography环境重定义(过程中设置list环境的参数),这是传统参考文献生成的方法。(2) 通过定义defbibenvironment命令重定义bibliography环境来实现的,这是基于biblatex生成参考文献的方法。

而我们有时有需求希望将参考文献放在一个大框架里面,如果参考文献表作为整体放入,那么实现是比较简单的,只要在在参考文献表外面加上需要的框架即可。然而如果要将参考文献表中的每条参考文献单独的放入框架中,比如将参考文献表以表格形式来显示,即将每一条参考文献作为表格的一行来显示,显然这是一个比较麻烦的问题。

传统参考文献生成的方法,由于thebibliography环境是显示的核心,必须要对其做定义修改,比如在其内部使用表格,同时仍然兼具文献引用关联和超链接的功能。对于每条参考文献则需要显式的给出表格内容所需格式即加入&\hline等命令,这通过手写或者修改bst样式来直接在bbl文件中输出。上述虽然应该都可以实现,但却是一个相当复杂的过程。

而基于biblatex生成参考文献的方法,由于其完全获取参考文献信息的特点在这种复杂任务中是有优势的,可以比较方便的实现上述目标)。下面我们来介绍怎么操作。

2. 原理

biblatex生成参考文献完全是在tex环境中进行,因此每一条参考文献的输出实质上是一个递归的解析数据并输出数据的过程,在这个过程中如果我们能够在输出的过程中添加上表格格式的标识命令,并在全部参考文献信息外面套上一个表格环境就能够得到表格形式的参考文献表。而这个功能是由biblatex-ext 宏包完成了,因此对于我们使用者来说,问题就会简单得多了,只要学会使用即可。

表格形式的文献输出命令为:|\printbibtabular
其参数类似于\printbibliography,用法也相同。

其输出格式本质上是由|\defbibtabular定义的bibtabular环境决定的,所以我们要生成什么样的表格就是要定义什么样的bibtabular环境。

比如:

\defbibtabular{bibtabular}
  {\begin{longtable}{|c|p{0.85\textwidth}|}
     \hline
     序号 & 文献目录 \\
     \hline}
  {\end{longtable}}
  {\anchor{\printfield{labelnumber}} & \driver{}\\\hline}
\end{codetex}

基于上述设置,我们就可以利用printbibtabular输出一个两列的简单表格的文献表。

3. 实践

上面给出表格设置是比较简单的,展示基本原理,下面我们给出两个稍复杂的示例,内容不多介绍了,读者可以直接下载代码运行。

示例一:将作者和文献标题分两列显示

\documentclass{ctexart}

\usepackage[style=gb7714-2015]{biblatex}
\usepackage{biblatex-ext-tabular}

\usepackage{array,longtable}

\newcolumntype{L}[1]{%
  >{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\defbibtabular{bibtabular}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{%
     @{}
     |L{\dimexpr0.35\textwidth-\tabcolsep\relax}|
      L{\dimexpr0.65\textwidth-\tabcolsep\relax}|
     @{}}
     \hline
     \textbf{Author} & \textbf{Title}\\
     \hline
     \endfirsthead}
  {\end{longtable}}
  {\anchor{\printnames{author}}
   & \plainlang{\printfield{title}}\\\hline}

\begin{filecontents}{\jobname.bib}
@book{brooks_TroublingConfessionsSpeaking_2000,
  title = {Troubling {{Confessions}}: Speaking {{Guilt}} in {{Law}} and {{Literature}}},
  author = {Brooks, Peter},
  date = {2000},
  publisher = {{University of Chicago Press}},
  location = {{Chicago}}
}

@article{chamberlain_SearchCivilSociety_1993,
  title = {On the {{Search}} for {{Civil Society}} in {{China}}},
  author = {Chamberlain, Heath B.},
  date = {1993-04},
  volume = {19},
  number = {2},
  pages = {199--215}
}

@incollection{duwei*fokema_ZouXiangXinShiJieZhuYi_1999,
  title = {走向新世界主义},
  booktitle = {全球化与后殖民批评},
  author = {杜威·佛克马},
  editor = {王宁 and 薛晓源},
  date = {1999},
  pages = {247--266},
  publisher = {中央编译出版社},
  location = {北京}
}

@thesis{fangmingdong_LuoLongJiZhengZhiSiXiangYanJiu19131949_2000,
  type = {博士},
  title = {罗隆基政治思想研究(1913—1949)},
  author = {方明东},
  date = {2000},
  institution = {北京师范大学历史系},
  location = {北京}
}

@incollection{schfield_ImpactScarcityPlenty_1983,
  title = {The {{Impact}} of {{Scarcity}} and {{Plenty}} on {{Population Change}} in {{England}}},
  booktitle = {Hunger and {{History}}: The {{Impact}} of {{Changing Food Production}} and {{Consumption Pattern}} on {{Society}}},
  author = {Schfield, R. S.},
  editor = {Rotberg, R. I. and Rabb, T. K.},
  date = {1983},
  pages = {55--88},
  publisher = {{Cambridge University Press}},
  location = {{Cambridge, MA}}
}

@book{shitenghuixiu_ZhongGuoRenLiuXueRiBenShi_1982,
  title = {中国人留学日本史},
  author = {实藤惠秀},
  translator = {谭汝谦 and 林启彦},
  date = {1982},
  publisher = {香港中文大学出版社},
  location = {香港}
}

@article{weiliying_LunJinDaiXiBeiRenKouBoDongDeZhuYaoYuanYin_1990,
  title = {论近代西北人口波动的主要原因},
  author = {{魏丽英}},
  date = {1990},
  journaltitle = {社会科学},
  number = {6}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\printbibtabular
\end{document} 

结果为:

在这里插入图片描述

示例二:将序号和文献内容分两列显示

\documentclass{ctexart}

\usepackage[style=gb7714-2015]{biblatex}
\usepackage{biblatex-ext-tabular}

\usepackage{array,longtable,booktabs}

\newcolumntype{L}[1]{%
  >{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
  
\newcolumntype{C}[1]{%
  >{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\defbibtabular{bibtabular}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{%
     @{}
     |C{\dimexpr0.15\textwidth-\tabcolsep\relax}|
      L{\dimexpr0.85\textwidth-\tabcolsep\relax}|
     @{}}
     \hline
     序号 & \multicolumn{1}{c|}{作者、标题等文献信息}\\
     \hline
     \endfirsthead}
  {\end{longtable}}
  {\anchor{\mkgbnumlabel{\printfield{labelnumber}}}
   & \driver{} \\\hline}
   

\begin{filecontents}{\jobname.bib}
@book{brooks_TroublingConfessionsSpeaking_2000,
  title = {Troubling {{Confessions}}: Speaking {{Guilt}} in {{Law}} and {{Literature}}},
  author = {Brooks, Peter},
  date = {2000},
  publisher = {{University of Chicago Press}},
  location = {{Chicago}}
}

@article{chamberlain_SearchCivilSociety_1993,
  title = {On the {{Search}} for {{Civil Society}} in {{China}}},
  author = {Chamberlain, Heath B.},
  date = {1993-04},
  volume = {19},
  number = {2},
  pages = {199--215}
}

@incollection{duwei*fokema_ZouXiangXinShiJieZhuYi_1999,
  title = {走向新世界主义},
  booktitle = {全球化与后殖民批评},
  author = {杜威·佛克马},
  editor = {王宁 and 薛晓源},
  date = {1999},
  pages = {247--266},
  publisher = {中央编译出版社},
  location = {北京}
}

@thesis{fangmingdong_LuoLongJiZhengZhiSiXiangYanJiu19131949_2000,
  type = {博士},
  title = {罗隆基政治思想研究(1913—1949)},
  author = {方明东},
  date = {2000},
  institution = {北京师范大学历史系},
  location = {北京}
}

@incollection{schfield_ImpactScarcityPlenty_1983,
  title = {The {{Impact}} of {{Scarcity}} and {{Plenty}} on {{Population Change}} in {{England}}},
  booktitle = {Hunger and {{History}}: The {{Impact}} of {{Changing Food Production}} and {{Consumption Pattern}} on {{Society}}},
  author = {Schfield, R. S.},
  editor = {Rotberg, R. I. and Rabb, T. K.},
  date = {1983},
  pages = {55--88},
  publisher = {{Cambridge University Press}},
  location = {{Cambridge, MA}}
}

@book{shitenghuixiu_ZhongGuoRenLiuXueRiBenShi_1982,
  title = {中国人留学日本史},
  author = {实藤惠秀},
  translator = {谭汝谦 and 林启彦},
  date = {1982},
  publisher = {香港中文大学出版社},
  location = {香港}
}

@article{weiliying_LunJinDaiXiBeiRenKouBoDongDeZhuYaoYuanYin_1990,
  title = {论近代西北人口波动的主要原因},
  author = {{魏丽英}},
  date = {1990},
  journaltitle = {社会科学},
  number = {6}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\printbibtabular
\end{document} 

结果为:

在这里插入图片描述

4. 小结

本文给出了latex中基于biblatex的参考文献生成方法中产生表格式的文献表的方法。用户可以通过自定义表格格式的方式比较方便的生成表格文献表,这有赖于biblatex维护者对于biblatex-ext的实现。这个功能也进一步展现了latex中biblatex生成参考文献表的强大能力。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值