%EB%8A%94%20%EB%82%A0%EC%A7%9C%EA%B0%80%20%EB%B9%84%EC%96%B4%20%EC%9E%88%EC%9C%BC%EB%A9%B4%20%EB%B9%88%20%EA%B4%84%ED%98%B8%EB%A5%BC%20%EB%84%A3%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
pubstate
아직 출판 날짜가 없는(빈 날짜 필드) "준비 중인" 출판물에 대해 BibLaTeX' 필드를 사용하고 싶습니다. 예를 들어, 저자 연도 스타일은 다음과 같습니다.
@Article{Test,
author = {Author, A.},
journaltitle = {A Journal},
title = {A Title},
pubstate = {inpreparation},
}
그러나 저널 이름 뒤에 빈 괄호가 남습니다.
\documentclass{article}
\usepackage[backend=biber, style=authoryear]{biblatex}
\addbibresource{Bib2.bib}
\begin{document}
Test \parencite{Test}.
\printbibliography
\end{document}
이것을 어떻게 제거할 수 있나요?
답변1
여기서 근본적인 문제는 동료와 달리 \print(field|list|names|date)
명령이 \printtext
무언가를 인쇄할지 여부를 미리 알 수 없다는 것입니다. 따라서 나중에 아무것도 인쇄되지 않는 것으로 밝혀지더라도 항상 서식 지정 인수를 적용합니다. 여기서 이는 빈 괄호 쌍으로 끝나는 것을 의미합니다.
이를 해결하는 한 가지 방법은 호출하기 전에 무언가를 인쇄할지 확인하는 것입니다 \printtext
.
일부 biblatex
코드는 \ifthenelse
대부분의 최신 코드 etoolbox
를 사용하지만 ' \ifboolexpr
. 내부적으로 biblatex
필드가 없기 때문에 date
a의 존재 여부를 테스트하려면 date
다음을 테스트하는 것이 좋습니다.year
\renewbibmacro*{issue+date}{%
\ifboolexpr{test {\iffieldundef{issue}} and test {\iffieldundef{year}}}
{}
{\printtext[parens]{%
\printfield{issue}%
\setunit*{\addspace}%
\usebibmacro{date}}%
\newunit}}
또한보십시오https://github.com/plk/biblatex/issues/793.
최근에 자동으로 인쇄 여부를 확인하고 그렇지 않은 경우 서식을 억제하는 biblatex-apa
버전을 구현한 일부 사람들은 관심을 가질 수 있습니다 . \printtext
보다https://github.com/plk/biblatex-apa/pull/99. 이 명령에 부정적인 부작용이 없는 것으로 밝혀지면 이를 코어로 옮기는 것을 고려할 수 있지만 biblatex
더 많은 테스트가 필요합니다(그리고 구현이 부정행위처럼 느껴집니다).
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\renewbibmacro*{issue+date}{%
\printtexte[parens]{%
\printfield{issue}%
\setunit*{\addspace}%
\usebibmacro{date}}%
\newunit}
% implement \printtexte
\makeatletter
% Optional parens/brackets
% Thanks to egreg from https://tex.stackexchange.com/questions/53068/how-to-check-if-a-macro-value-is-empty-or-will-not-create-text-with-plain-tex-co
% for this test for expanded emptiness so that we can easily opt to not print parens around nothing
% Without this, it is very messy - you have to test all potential fields for defness first and this
% is messy because the fields in the additional info vary betwee entrytypes
\def\foreverunspace{%
\ifnum\lastnodetype=11
\unskip\foreverunspace
\else
\ifnum\lastnodetype=12
\unkern\foreverunspace
\else
\ifnum\lastnodetype=13
\unpenalty\foreverunspace
\fi
\fi
\fi
}
% we need a way to save the state of the punctuation buffer
% cf. \blx@initunit in biblatex.sty for what we need to copy
% this uses the internal implementation of etoolbox toggles
% fingers crossed no one messes with it
\newrobustcmd*{\apablx@savetoggle}[1]{%
\csletcs{apablx@savedtoggle@#1}{etb@tgl@#1}}
\newrobustcmd*{\apablx@restoretoggle}[1]{%
\csletcs{etb@tgl@#1}{apablx@savedtoggle@#1}}
\newrobustcmd*{\apablx@savepunctstate}{%
\apablx@savetoggle{blx@block}%
\apablx@savetoggle{blx@unit}%
\apablx@savetoggle{blx@insert}%
\apablx@savetoggle{blx@lastins}%
\apablx@savetoggle{blx@keepunit}%
\let\apablx@savd@unitpunct\blx@unitpunct
\let\apablx@savd@puncthook\abx@puncthook}
\newrobustcmd*{\apablx@restorepunctstate}{%
\global\apablx@restoretoggle{blx@block}%
\global\apablx@restoretoggle{blx@unit}%
\global\apablx@restoretoggle{blx@insert}%
\global\apablx@restoretoggle{blx@lastins}%
\global\apablx@restoretoggle{blx@keepunit}%
\global\let\blx@unitpunct\apablx@savd@unitpunct
\global\let\abx@puncthook\apablx@savd@puncthook}
% printtext that checks if it would print anything
\newrobustcmd{\printtexte}[2][]{%
\apablx@savepunctstate
\setbox0=\hbox{#2\foreverunspace}%
\apablx@restorepunctstate
\ifdim\wd0=0pt
\else
\ifblank{#1}
{\printtext{#2}}
{\printtext[#1]{#2}}%
\fi}
\makeatother
\begin{filecontents}{\jobname.bib}
@article{test,
author = {Author, A.},
journaltitle = {A Journal},
title = {A Title},
pubstate = {inpreparation},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\autocite{test}
\printbibliography
\end{document}
답변2
해결책을 찾았습니다.
\renewbibmacro*{issue+date}{%
\ifthenelse{\ifentrytype{article}\AND\iffieldundef{date}\AND\iffieldundef{issue}}
{}
{\ifthenelse{\iffieldundef{issue}}
{}
{\printtext[parens]{%
\printfield{issue}%
\setunit*{\addspace}%
\usebibmacro{date}}}}%
\newunit}