latex - 如何使用 BibLaTeX 从文本引用中添加冒号并删除“p/pp”?
问题描述
我在一篇论文中引用了哈佛风格,我想稍微编辑一下文本引用的方式。我正在使用 Biblatex,并且我使用了一些规范来制作符合哈佛参考的文本引用和参考书目,所以这一切都很好。
然而,文本内的引文看起来并不像我想要的那样。年份和页码用逗号分隔,但我想要一个冒号,并且在页码之前插入“p/pp”。我宁愿删除它。
目前,我的 pre-amb 如下所示:
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{soul}
\usepackage{tabularx}
\usepackage{dcolumn}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{fancyhdr}
\setlength{\headsep}{1.2cm}
\setlength{\headheight}{14.5pt}
\pagestyle{fancy}
\lhead{Header}
\chead{Headrer}
\rhead{Header}
\usepackage{setspace}
\doublespacing
\usepackage{listings}
\usepackage{color}
\usepackage{subcaption}
\usepackage{hanging}
\usepackage[english]{babel}
\usepackage[babel]{csquotes}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage[style=ext-authoryear, giveninits=true, uniquename=init, backend=biber, maxbibnames=99, innamebeforetitle = true,]{biblatex}
\DeclareNameAlias{default}{last-first}
\DeclareNameAlias{author}{last-first}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}
\DeclareFieldAlias{translatortype}{editortype}
\DeclareDelimAlias{translatortypedelim}{editortypedelim}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\nocite{*}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\makeatletter
\renewbibmacro*{bbx:in:editor}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\ifboolexpr{togl {bbx:innameidem} and test {\bbx@ineditoridem}}
{\bibstring[\mkibid]{idem\thefield{gender}}}
{\printnames[ineditor][1-42]{editor}}%
\setunit{\printdelim{editortypedelim}}%
\usebibmacro{#1}%
\clearname{editor}}
{}}
\makeatother
\newcommand\chap[1]{
\chapter*{#1}
\addcontentsline{toc}{chapter}{#1}
\markboth{#1}{#1}}
\newcommand\secTOC[1]{
\section*{#1}
\addcontentsline{toc}{section}{#1}
\markboth{#1}{#1}}
\raggedbottom
\begin{document}
\noindent Example sentence \parencite[20-22]{Andreadisetal}. Another sentence \parencite[30-31]{Bruns&Highfield}.
\printbibliography
\end{document}
参考文献是:
@InCollection{Andreadisetal,
author = {Andreadis, I. and Cremonesi, C. and Kartsounidou, E. and Kasprowicz, D. and Hess, A.},
title = {Attitudinal and Behavioral Responses to Populist Communication: The Impact of Populist Message Elements on Populist Attitudes and Voting Intentions},
booktitle = {Communicating populism: comparing actor perceptions, media coverage, and effects on citizens in Europe},
year = {2019},
publisher = {Routledge},
location = {New York},
editor = {Reinemann, C. and Stanyer, J. and Aalberg, T. and Esser, F. and De Vreese, C.H.},
}
@InCollection{Bruns&Highfield,
author = {Bruns, A. and Highfield, T.},
title = {Is Habermas on Twitter? Social Media and the Public Sphere},
booktitle = {The Routledge Companion to Social Media and Politics},
year = {2016},
editor = {Bruns, A. and Enli, G. and Skogerbø, E. and Larsson, A.O. and Christensen, C.},
publisher = {Routledge},
location = {New York},
}
当我运行它时,输出如下所示:
但我希望它是:(Andreadis et al., 2019: 20-22) and Bruns and Highfield, 2016: 30-31) 在年份和页面之间使用冒号而不是逗号,并完全放弃 p/pp .
我可以使用哪些选项来执行此操作?
解决方案
您可以删除pp.
并p.
使用
\DefineBibliographyStrings{english}{%
page = {},
pages = {},
}
并用冒号替换命令:
\renewcommand{\postnotedelim}{\addcolon}
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{soul}
\usepackage{tabularx}
\usepackage{dcolumn}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{fancyhdr}
\setlength{\headsep}{1.2cm}
\setlength{\headheight}{14.5pt}
\pagestyle{fancy}
\lhead{Header}
\chead{Headrer}
\rhead{Header}
\usepackage{setspace}
\doublespacing
\usepackage{listings}
\usepackage{color}
\usepackage{subcaption}
\usepackage{hanging}
\usepackage[english]{babel}
\usepackage[babel]{csquotes}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
%\usepackage{fontspec}
%\setmainfont{Times New Roman}
\usepackage[style=ext-authoryear, giveninits=true, uniquename=init, backend=biber, maxbibnames=99, innamebeforetitle = true,]{biblatex}
\DeclareNameAlias{default}{last-first}
\DeclareNameAlias{author}{last-first}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}
\DeclareFieldAlias{translatortype}{editortype}
\DeclareDelimAlias{translatortypedelim}{editortypedelim}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\nocite{*}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\makeatletter
\renewbibmacro*{bbx:in:editor}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\ifboolexpr{togl {bbx:innameidem} and test {\bbx@ineditoridem}}
{\bibstring[\mkibid]{idem\thefield{gender}}}
{\printnames[ineditor][1-42]{editor}}%
\setunit{\printdelim{editortypedelim}}%
\usebibmacro{#1}%
\clearname{editor}}
{}}
\makeatother
\newcommand\chap[1]{
\chapter*{#1}
\addcontentsline{toc}{chapter}{#1}
\markboth{#1}{#1}}
\newcommand\secTOC[1]{
\section*{#1}
\addcontentsline{toc}{section}{#1}
\markboth{#1}{#1}}
\raggedbottom
\begin{filecontents*}{\jobname.bib}
@InCollection{Andreadisetal,
author = {Andreadis, I. and Cremonesi, C. and Kartsounidou, E. and Kasprowicz, D. and Hess, A.},
title = {Attitudinal and Behavioral Responses to Populist Communication: The Impact of Populist Message Elements on Populist Attitudes and Voting Intentions},
booktitle = {Communicating populism: comparing actor perceptions, media coverage, and effects on citizens in Europe},
year = {2019},
publisher = {Routledge},
location = {New York},
editor = {Reinemann, C. and Stanyer, J. and Aalberg, T. and Esser, F. and De Vreese, C.H.},
}
@InCollection{Bruns&Highfield,
author = {Bruns, A. and Highfield, T.},
title = {Is Habermas on Twitter? Social Media and the Public Sphere},
booktitle = {The Routledge Companion to Social Media and Politics},
year = {2016},
editor = {Bruns, A. and Enli, G. and Skogerbø, E. and Larsson, A.O. and Christensen, C.},
publisher = {Routledge},
location = {New York},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\DefineBibliographyStrings{english}{%
page = {},
pages = {},
}
\renewcommand{\postnotedelim}{\addcolon}
\begin{document}
\noindent Example sentence \parencite[20-22]{Andreadisetal}. Another sentence \parencite[30-31]{Bruns&Highfield}.
\printbibliography
\end{document}
推荐阅读
- vim - 匹配具有不同前面零宽度模式的相同字符串
- drupal - 在 Drupal 8 中以编程方式保存 geofield
- android - 在 Samsung Galaxt S9 (Oreo) 上显示安全异常
- xml - 在命名空间定义中使用变量
- botframework - Botframework WebChat:无法在其他聊天/浏览器上开始新的和干净的对话
- php - Ajax 获取表单 PHP MySQL 的提交按钮的动态 id
- nfc - 如何开始与 ACR122U-A9 NFC 读写器交互?
- java - java将结果集转换为列表
- cordova - 基于 Cordova 的应用程序启动画面延迟不适用于 Windows 10 版本
- java - 基于 java 的项目环境设置的 sonar.java.binaries 属性中的错误