나는 모든 구두 및 포스터 프레젠테이션을 구성하는 데 사용하는 BibLaTeX 라이브러리를 만들었습니다. 이는 실제로 새로운 데이터 유형과 인용 명령을 갖춘 맞춤형 라이브러리입니다. 나는 모든 아이디어를 얻었습니다.여기그리고여기.
프로그래밍을 한 후 다음과 같은 코드를 얻었는데 꽤 잘 작동했습니다. 어떤 텍스트에서든 내 자신의 명령을 사용할 수 있지만 \printcontrib{BiB_entry}
마지막 명령을 통해 모든 Bib 항목을 호출하여 마지막에 일부 목록을 작성할 수도 있습니다. 코드를 보여드리기 전에, 제 코드가 아마도 (사악한?) 해킹일 수도 있다는 점을 사과드리고 싶습니다. ;-)
MWE
\RequirePackage{filecontents}
% The BibTeX library
\begin{filecontents*}{\jobname.bib}
@Contribution{Oral_2016_1,
Type = {Oral},
Invited = {True},
Author = {{\textbf{Author, One} and Author, Two and Author, Three}},
Presenter = {{Author, One}},
Title = {{Some cool stuff about the Nanoworld}},
Event = {{Conference about XYZ}},
Eventtype = {Conference},
Place = {},
City = {Helsinki (Finland) - Stockholm (Sweden)},
Country = {},
Date = {May 1$^{\rm st}$ - June 2$^{\rm nd}$},
Period = {},
Year = {2016},
Note = {}
}
@Contribution{Oral_2015_1,
Type = {Oral},
Invited = {Ture},
Author = {{\textbf{Author, One}}},
Presenter = {{Author, One}},
Title = {{Exciting research on cool Nanostuff}},
Event = {{6$^{\rm th}$ Nanotechnology workshop}},
Eventtype = {Workshop},
Place = {},
City = {Giessen},
Country = {Germany},
Date = {September 24$^{\rm th}$},
Period = {},
Year = {2015},
Note = {}
}
@Contribution{Oral_2015_2,
Type = {Oral},
Invited = {False},
Author = {{Author, One and Author, Two and \textbf{Author, Three}}},
Presenter = {{Author, Three}},
Title = {{Nanochemistry at its edge}},
Event = {{18$^{\rm th}$ Summer School of Nanochemistry}},
Eventtype = {School},
Place = {},
City = {Cassis},
Country = {France},
Date = {September 9$^{\rm th}$},
Period = {},
Year = {2015},
Note = {}
}
\end{filecontents*}
% The declaration of the entries.
\begin{filecontents}{contribution.dbx}
\DeclareDatamodelEntrytypes{contribution}
\DeclareDatamodelFields[type=field,datatype=literal]{
type,
invited,
title,
event,
eventtype,
place,
city,
country,
date,
period,
year,
note
}
\DeclareDatamodelFields[type=list,datatype=name]{
author,
presenter
}
\DeclareDatamodelEntryfields[contribution]{
type,
invited,
author,
presenter,
title,
event,
eventtype,
place,
city,
country,
date,
period,
year,
note}
\end{filecontents}
% The standard LaTeX head, with a link to the chem-acs style and biber. The
% datamodel 'contribution' is also declared.
\documentclass[english]{book}
\usepackage{babel}
\usepackage{ifmtarg}
\usepackage{xstring}
\usepackage{ifthen}
\usepackage[datamodel=contribution,
style=chem-acs,
natbib=true,
backend=biber]
{biblatex}
\addbibresource{\jobname.bib}
% Declare cite commands, the most important ones. Others will be added.
\DeclareCiteCommand{\citeevent}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext{\printfield{event}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citedate}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext{\printfield{date}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeyear}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext{\printfield{year}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citecity}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext{\printfield{city}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citecountry}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext{\printfield{country}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citetitle}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext{\printfield{title}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand*{\citeauthor}
{\defcounter{maxnames}{99}%
\defcounter{minnames}{99}%
\defcounter{uniquename}{2}%
\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex{\indexnames{labelname}}{}\printnames{labelname}}
{\multicitedelim}
{\usebibmacro{postnote}}
% My own command, which puts into format and prints the contribution.
\newcommand{\printcontrib}[1]{
\citeauthor*{#1},
\citetitle*{#1},
\citeevent{#1},
\citecity{#1}
%
% This works, but there is no 'if' that might find an empty 'country' field.
% I would like to have:
% If : Country = {} => Do not print '(\citecountry{#1})'
% Else: print (\citecountry{#1})
(\citecountry{#1}),
%
%
% Here is my first test amongst many others:
% It works but there is a error: "! Illegal unit of measure (pt inserted)."
%
% \newlength{\strlen}\settowidth{\strlen}{\citecountry{#1}}
% \ifdim\strlen=0\else(\citecountry{#1})\fi,
% \let\strlen\relax
%
\citedate{#1} (\citeyear{#1})
}
\begin{document}
\chapter{Oral contributions}
\printcontrib{Oral_2016_1}\\\\
%
\noindent\printcontrib{Oral_2015_2}\\\\
%
\noindent\printcontrib{Oral_2015_1}\\\\
%
\end{document}
여태까지는 그런대로 잘됐다. 이제 하나의 BibLaTeX 항목(예: Oral_2016_1 => Country = {} 참조)에 일부 정보가 누락되어 두 개의 {} 안에 텍스트가 없는 일부 항목이 있을 수 있습니다. 몇 가지 이유 때문에 ... .)
항목이 '비어 있는지' 확인하는 'if ... do ... else do ...' 부분을 코드에 포함하고 싶습니다 Country = {}
. 그렇지 않으면 여기의 경우처럼 텍스트()에 두 개의 대괄호가 표시됩니다.
특히 이 명령에서 조건을 지정하는 경우 다음을 갖고 싶습니다.
% My own command, which puts into format and prints the contribution.
\newcommand{\printcontrib}[1]{
\citeauthor*{#1},
\citetitle*{#1},
\citeevent{#1},
\citecity{#1}
%
% This works, but there is no 'if' that might find an empty 'country' field.
% I would like to have:
% If : Country = {} => Do not print '(\citecountry{#1})'
% Else: print (\citecountry{#1})
(\citecountry{#1}),
%
%
% Here is my first test amongst many others:
% It works but there is a error: "! Illegal unit of measure (pt inserted)."
%
% \newlength{\strlen}\settowidth{\strlen}{\citecountry{#1}}
% \ifdim\strlen=0\else(\citecountry{#1})\fi,
% \let\strlen\relax
%
\citedate{#1} (\citeyear{#1})
}
명령 ( 및 대괄호 (\citecountry{#1})
참고 )은 항목 에 일부 텍스트가 있는 경우, 즉 BibLaTeX 파일에 없는 경우에만 실행됩니다 .(
)
country
Country = {}
나는 수십 가지를 시험해 보았습니다. 예를 들어 ifmtarg
, xstring
및 패키지 의 도움으로 여러 if 조건을 시도했지만 ifthen
성공하지 못했습니다. 그러나 half-solution
% 인용문(MWE의 텍스트 아래)에 있는 유일한 내용은 % Here is my first test
어느 정도 작동하지만 오류가 있습니다(LaTeX로 컴파일되도록 주석 처리를 제거해야 합니다).
답변1
에서는 biblatex
대괄호, 강조 또는 기울임꼴과 같은 필드 형식을 대부분의 경우 매크로에 직접 작성해서는 안 되며 를 사용하여 수행해야 합니다 \DeclareFieldFormat
. 이렇게 하면 biblatex
빈 필드를 올바르게 감지하고 이 경우 아무 작업도 수행할 수 없는지 확인할 수 있습니다 .
넌 그냥 할 수도 있어
\DeclareFieldFormat{country}{\mkbibparens{#1}}
\DeclareCiteCommand{\citecountry}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printfield{country}}
{\multicitedelim}
{\usebibmacro{postnote}}
그런 다음 필드는 표시될 때마다 대괄호로 묶이고 그렇지 않으면 무시됩니다. \printfield
인수 \printtext
없이 싱글을 래핑할 필요가 없으며 \printfield{country}
와 동일하게 수행됩니다 \printtext{\printfield{country}}
.
지금처럼 정의하는 대신 \citecontrib
참고문헌 드라이버를 정의해야 할 것입니다. @contribution
(이것은 단지 첫 번째 대략적인 작업이지만 아이디어를 얻으실 수 있습니다.)
\DeclareFieldFormat{country}{\mkbibparens{#1}}
\DeclareFieldFormat[contribution]{title}{\mkbibemph{#1}}
\newbibmacro*{event+venue+city+country+date}{%
\printfield{eventtitle}%
\newunit
\printfield{eventtitleaddon}%
\newunit
\printeventdate
\newunit
\printfield{city}
\setunit{\addspace}%
\printfield{country}
\newunit}
\DeclareBibliographyDriver{contribution}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{event+venue+city+country+date}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{location+date}\printdate%
\newunit\newblock
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}
그런 다음 사용하면 \fullcite
완료됩니다.
답변2
\DeclareCiteCommand
필드가 사용 \iffieldundef
(또는 이와 유사한 것) 의 일부로 존재하는지 확인해야 합니다 . 섹션을 참조하세요.4.6.2 독립형 테스트에서biblatex
선적 서류 비치):
\DeclareCiteCommand{\citecountry}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\iffieldundef{country}{}{(\printtext{\printfield{country}})}}
{\multicitedelim}
{\usebibmacro{postnote}}
그리고 여기 있습니다 \printcontrib
:
\newcommand{\printcontrib}[1]{%
\citeauthor*{#1},
\citetitle*{#1},
\citeevent{#1},
\citecity{#1}
\citecountry{#1},
\citedate{#1} (\citeyear{#1})
}
\DeclareCiteCommand
를 사용하는 대신 더 크게 작성할 수도 있습니다 \printcontrib
.