BibLaTeX : @thesis 항목에서 "학교"뒤의 쉼표를 제거하려면 어떻게해야합니까?

Aug 15 2020

@thesis 참고 문헌 항목에서 "school"필드와 날짜 (연도) 사이의 쉼표를 제거하고 싶습니다.

다음은 최소한의 예제 코드입니다.

\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바로 앞에 추가 할 수 있습니다 . 예제의 문서 클래스를 . 이름에도 불구하고 문서 클래스는 실제로 너무 최소이므로 MWE에 사용 해서는 안됩니다 . 이제 LaTeX 커널의 일부인 패키지 도 제거했습니다 .\newunitinstitution+location+datearticleminimalfilecontents

\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}

Alan이 답변 아래의 주석에서 설명했듯이 biblatex의 구두점 처리는 비동기식입니다. 구두점은 버퍼에 저장되고 필요할 때만 인쇄됩니다 (즉, 다음 \print...명령이 실제로 무언가를 인쇄 할 때). 질문의 코드에서 \usebibmacro{date}in institution+location+date은 실제로 날짜를 인쇄하지 않기 때문에 \setunit이전은 궁극적으로 날짜 이전의 구두점을 제어하지 않습니다. 날짜는 date:printin 로만 인쇄되며 chapter+pages,이 시점에서 다른 \setunit명령은 버퍼에 다른 구두점을 추가합니다.

\nopunct\print...명령으로 새 내용 / 텍스트를 인쇄 할 때까지 구두점을 인쇄하지 않도록 영구 마커를 설정합니다 . 이 경우 원하지 않는 기간을 억제하는 데 도움이됩니다. \nopunct구두점 추적기 안팎에서 사용할 수 있기 때문에 구두점을 조정할 수있는 편리한 도구이지만 일반적으로이를 피하고 사용하지 않는 솔루션을 선호합니다. 원하는 것 이상의 효과를 가질 수 있기 때문입니다.