BibLaTeX: ฉันจะลบเครื่องหมายจุลภาคหลัง "school" ในรายการ @thesis ได้อย่างไร

Aug 15 2020

ฉันต้องการลบเครื่องหมายจุลภาคระหว่างช่อง "โรงเรียน" กับวันที่ (ปี) ในรายการบรรณานุกรม @thesis:

นี่คือโค้ดตัวอย่างขั้นต่ำของฉัน:

\documentclass{minimal}

\usepackage{ngerman}
\usepackage[backend = biber, style = numeric]{biblatex}

%%%%%%%% https://tex.stackexchange.com/a/492917

\newtoggle{bbx:datemissing}

\renewbibmacro*{date}{\toggletrue{bbx:datemissing}%}

\renewbibmacro{volume+number+eid}{%
  \printfield{volume}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\renewbibmacro*{issue+date}{%
  \toggletrue{bbx:datemissing}%
  \iffieldundef{issue}{}{
    \printtext[parens]{%
    \printfield{issue}}}%
  \newunit}

\newbibmacro*{date:print}{%
  \togglefalse{bbx:datemissing}%
  \printdate}

\renewbibmacro*{chapter+pages}{%
  \printfield{chapter}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \usebibmacro{date:print}%
  \newunit}

\renewbibmacro*{note+pages}{%
  \printfield{note}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \usebibmacro{date:print}%
  \newunit}

%%%%%%%%

%%% This is what I came up with
\renewbibmacro{institution+location+date}{%
  \printlist{location}%
  \iflistundef{institution}{%
    \setunit*{\space}%
  }{%
    \setunit*{\addcolon\space}%
  }%
  \printlist{institution}%
  \setunit*{\space}%
  \usebibmacro{date}%
  \newunit%
}

\usepackage{filecontents}
\begin{filecontents*}{lit.bib}
  @thesis {mythesis,
    author = {Me, I.},
    school = {University},
    title = {Sometitle},
    type = {Phd thesis},
    year = {123}
  }  
\end{filecontents*}

\addbibresource{lit.bib}

\begin{document}
\printbibliography
\end{document}
\nocite{*}

ฉันลองแล้ว\renewbibmacro{institution+location+date}{...}แต่ไม่ได้ผล ฉันค่อนข้างใหม่กับ BibLaTeX

ความคิดของฉันคือnumericสไตล์ใช้ประเภทรายการจากstandardซึ่งมาจากที่ฉันคัดลอกมาโครและลบเครื่องหมายจุลภาคทั้งหมด อย่างไรก็ตามนั่นไม่ได้ผลอย่างชัดเจน ฉันจะลบเครื่องหมายจุลภาคนี้ได้อย่างไร

คำตอบ

3 AlanMunn Aug 15 2020 at 22:37

คุณสามารถเพิ่ม\nopunctก่อนมาโครที่\newunitกำหนดใหม่institution+location+dateได้ ฉันได้เปลี่ยนคลาสเอกสารของตัวอย่างของคุณเป็นarticle. แม้จะมีชื่อ แต่ไม่minimalควรใช้คลาสเอกสารสำหรับ MWE เนื่องจากมีน้อยเกินไป ฉันได้ลบแพ็คเกจซึ่งตอนนี้เป็นส่วนหนึ่งของเคอร์เนล LaTeX แล้วfilecontents

\documentclass{article}

\usepackage{ngerman}
\usepackage[backend = biber, style = numeric]{biblatex}

\newtoggle{bbx:datemissing}

\renewbibmacro*{date}{\toggletrue{bbx:datemissing}}

\renewbibmacro{volume+number+eid}{%
  \printfield{volume}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\renewbibmacro*{issue+date}{%
  \toggletrue{bbx:datemissing}%
  \iffieldundef{issue}{}{
    \printtext[parens]{%
    \printfield{issue}}}%
  \newunit}

\newbibmacro*{date:print}{%
  \togglefalse{bbx:datemissing}%
  \printdate}

\renewbibmacro*{chapter+pages}{%
  \printfield{chapter}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \usebibmacro{date:print}%
  \newunit}

\renewbibmacro*{note+pages}{%
  \printfield{note}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \usebibmacro{date:print}%
  \newunit}
%%% This is what I came up with
\renewbibmacro{institution+location+date}{%
  \printlist{location}%
  \iflistundef{institution}{%
    \setunit*{\space}%
  }{%
    \setunit*{\space}%
  }%
  \printlist{institution}%
  \setunit*{\space}%
  \usebibmacro{date}%
  \nopunct\newunit%
}

\begin{filecontents*}[overwrite]{\jobname.bib}
  @thesis {mythesis,
    author = {Me, I.},
    school = {University of Somewhere},
    title = {Sometitle},
    type = {Phd thesis},
    year = {1980}
  }  
\end{filecontents*}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

2 moewe Aug 16 2020 at 10:45

คำตอบสำหรับการเปลี่ยนลำดับของหน้าและปีใน Biblatexซึ่งมีรหัสที่คุณใช้อยู่นั้นใช้เครื่องมือที่ค่อนข้างทื่อเพื่อย้ายการdateพิมพ์หลังจากpagesนั้น สิ่งนี้อาจไม่ใช่สิ่งที่คุณต้องการหรือจำเป็นในทุกสถานการณ์

นี่คือการตั้งค่าที่ซับซ้อนกว่าเล็กน้อยซึ่งจะย้ายวันที่เฉพาะในกรณีที่มีpages(หรือ a chapter) ซึ่งอาจส่งผลให้ผลลัพธ์ทำงานได้ดีขึ้นเล็กน้อยสำหรับคุณในบางสถานการณ์

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[backend=biber, style=numeric]{biblatex}

\newtoggle{bbx:datesuppressed}

\renewbibmacro*{date}{%
  \ifboolexpr{
        test {\iffieldundef{pages}}
    and test {\iffieldundef{chapter}}}
    {\printdate}
    {\toggletrue{bbx:datesuppressed}}}

\renewbibmacro{volume+number+eid}{%
  \printfield{volume}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\renewbibmacro*{issue+date}{%
  \toggletrue{bbx:datesuppressed}%
  \iffieldundef{issue}
    {}
    {\printtext[parens]{%
       \printfield{issue}}}%
  \newunit}

\newbibmacro*{date:print}{%
  \iftoggle{bbx:datesuppressed}
    {\togglefalse{bbx:datesuppressed}%
     \printdate}
    {}}

\renewbibmacro*{chapter+pages}{%
  \printfield{chapter}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \usebibmacro{date:print}%
  \newunit}

\renewbibmacro*{note+pages}{%
  \printfield{note}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit
  \usebibmacro{date:print}%
  \newunit}

\renewbibmacro{institution+location+date}{%
  \printlist{location}%
  \iflistundef{institution}
    {\setunit*{\space}}
    {\setunit*{\addcolon\space}}%
  \printlist{institution}%
  \setunit*{\space}%
  \usebibmacro{date}%
  \newunit
}

\begin{filecontents*}{\jobname.bib}
@phdthesis{mythesis,
  author = {Me, I.},
  school = {University},
  title  = {Sometitle},
  year   = {123},
}  
\end{filecontents*}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\nocite{mythesis,sigfridsson,westfahl:space}
\printbibliography
\end{document}

ดังที่อลันอธิบายไว้ในความคิดเห็นภายใต้คำตอบของเขาการbiblatexจัดการเครื่องหมายวรรคตอนเป็นแบบอะซิงโครนัส: เครื่องหมายวรรคตอนจะถูกเก็บไว้ในบัฟเฟอร์และพิมพ์เพียงครั้งเดียวที่จำเป็นเท่านั้น (กล่าวคือเมื่อ\print...คำสั่งถัดไปพิมพ์บางสิ่งจริงๆ) เนื่องจากในรหัสในคำถาม\usebibmacro{date}in institution+location+dateไม่ได้พิมพ์วันที่จริง\setunitก่อนหน้านี้จึงไม่ได้ควบคุมเครื่องหมายวรรคตอนก่อนวันที่ วันที่จะพิมพ์โดยdate:printในchapter+pagesเท่านั้นซึ่ง\setunitคำสั่งอื่น ๆจะเพิ่มเครื่องหมายวรรคตอนที่แตกต่างกันลงในบัฟเฟอร์

\nopunctกำหนดเครื่องหมายถาวรไม่ให้พิมพ์เครื่องหมายวรรคตอนจนกว่าเนื้อหา / ข้อความใหม่จะถูกพิมพ์โดย\print...คำสั่ง ในกรณีนี้จะช่วยระงับช่วงเวลาที่ไม่ต้องการ เนื่องจาก\nopunctสามารถใช้ภายในและภายนอกตัวติดตามเครื่องหมายวรรคตอนจึงเป็นเครื่องมือที่มีประโยชน์ในการปรับแต่งเครื่องหมายวรรคตอน แต่โดยทั่วไปแล้วฉันพยายามหลีกเลี่ยงและไม่ต้องการใช้วิธีแก้ไขปัญหาเนื่องจากอาจมีเอฟเฟกต์ที่เกินกว่าที่ต้องการ