biblatex - custom citation with conditional clause
up vote
1
down vote
favorite
I have a custom footnote citation command defined by modifying this answer in the following way:
DeclareCiteCommand{citejournal} % to get the journal entry
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}} % to get author, title, journal, year
which works perfectly for .bib
entries that have all those fields.
But now I have a .bib
file consisting of many articles, but also some books (ergo without a journal entry) that I want to cite using this command.
How can I make a conditional that checks whether there is a journal
entry in the .bib
file, and changes the output accordingly?
I have tried playing around with the answers presented in this question, but apparently I am too unfamiliar with conditionals in LaTeX to make it work.
Any help is appreciated.
(I am aware that the simplest solution would be to define two separate commands for articles and books.)
MWI:
documentclass{article}
usepackage{filecontents}
begin{filecontents}{bib.bib}
@article{article,
author = {Vimes, Samuel},
title = {The Influence of Species Diversity in the City Watch},
journal = {Unseen University Non-Magical Journal},
date = {1988}
}
@book{book,
author = {Vimes, Samuel},
title = {How To Be A Good Copper},
date = {2002}
}
end{filecontents}
usepackage[backend=biber,maxcitenames=1,maxbibnames=2,
giveninits=true]{biblatex}
bibliography{bib.bib}
% usepackage{xstring} % for if clause
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}}} % to get author, title, journal, year
begin{document}
Article:\ cfootcite{article}
Book:\ cfootcite{book}
end{document}
biblatex conditionals
add a comment |
up vote
1
down vote
favorite
I have a custom footnote citation command defined by modifying this answer in the following way:
DeclareCiteCommand{citejournal} % to get the journal entry
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}} % to get author, title, journal, year
which works perfectly for .bib
entries that have all those fields.
But now I have a .bib
file consisting of many articles, but also some books (ergo without a journal entry) that I want to cite using this command.
How can I make a conditional that checks whether there is a journal
entry in the .bib
file, and changes the output accordingly?
I have tried playing around with the answers presented in this question, but apparently I am too unfamiliar with conditionals in LaTeX to make it work.
Any help is appreciated.
(I am aware that the simplest solution would be to define two separate commands for articles and books.)
MWI:
documentclass{article}
usepackage{filecontents}
begin{filecontents}{bib.bib}
@article{article,
author = {Vimes, Samuel},
title = {The Influence of Species Diversity in the City Watch},
journal = {Unseen University Non-Magical Journal},
date = {1988}
}
@book{book,
author = {Vimes, Samuel},
title = {How To Be A Good Copper},
date = {2002}
}
end{filecontents}
usepackage[backend=biber,maxcitenames=1,maxbibnames=2,
giveninits=true]{biblatex}
bibliography{bib.bib}
% usepackage{xstring} % for if clause
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}}} % to get author, title, journal, year
begin{document}
Article:\ cfootcite{article}
Book:\ cfootcite{book}
end{document}
biblatex conditionals
2
I strongly recommend not to build upcite
commands from othercite...
commands. Commands defined likecfootcite
usually can't deal with multiple citations (cfootcite{sigfridsson,nussbaum}
) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute severalcite...
-like macros at once. Commands like these are better defined withDeclareCiteCommand
. The additional advantage ofDeclareCiteCommand
for your case is that ...
– moewe
yesterday
2
... additional information about the entry is available directly (such as the entry type), which can be used to deal with conditional formatting for entry types directly. Note how Audrey's answer to tex.stackexchange.com/a/29931/35864 uses just oneDeclareCiteCommand
and declares everything within that one command.
– moewe
yesterday
@moewe Thanks for the recommendation, I had noticed that it was misbehaving when trying to cite multiple sources.
– Taunch
16 hours ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a custom footnote citation command defined by modifying this answer in the following way:
DeclareCiteCommand{citejournal} % to get the journal entry
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}} % to get author, title, journal, year
which works perfectly for .bib
entries that have all those fields.
But now I have a .bib
file consisting of many articles, but also some books (ergo without a journal entry) that I want to cite using this command.
How can I make a conditional that checks whether there is a journal
entry in the .bib
file, and changes the output accordingly?
I have tried playing around with the answers presented in this question, but apparently I am too unfamiliar with conditionals in LaTeX to make it work.
Any help is appreciated.
(I am aware that the simplest solution would be to define two separate commands for articles and books.)
MWI:
documentclass{article}
usepackage{filecontents}
begin{filecontents}{bib.bib}
@article{article,
author = {Vimes, Samuel},
title = {The Influence of Species Diversity in the City Watch},
journal = {Unseen University Non-Magical Journal},
date = {1988}
}
@book{book,
author = {Vimes, Samuel},
title = {How To Be A Good Copper},
date = {2002}
}
end{filecontents}
usepackage[backend=biber,maxcitenames=1,maxbibnames=2,
giveninits=true]{biblatex}
bibliography{bib.bib}
% usepackage{xstring} % for if clause
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}}} % to get author, title, journal, year
begin{document}
Article:\ cfootcite{article}
Book:\ cfootcite{book}
end{document}
biblatex conditionals
I have a custom footnote citation command defined by modifying this answer in the following way:
DeclareCiteCommand{citejournal} % to get the journal entry
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}} % to get author, title, journal, year
which works perfectly for .bib
entries that have all those fields.
But now I have a .bib
file consisting of many articles, but also some books (ergo without a journal entry) that I want to cite using this command.
How can I make a conditional that checks whether there is a journal
entry in the .bib
file, and changes the output accordingly?
I have tried playing around with the answers presented in this question, but apparently I am too unfamiliar with conditionals in LaTeX to make it work.
Any help is appreciated.
(I am aware that the simplest solution would be to define two separate commands for articles and books.)
MWI:
documentclass{article}
usepackage{filecontents}
begin{filecontents}{bib.bib}
@article{article,
author = {Vimes, Samuel},
title = {The Influence of Species Diversity in the City Watch},
journal = {Unseen University Non-Magical Journal},
date = {1988}
}
@book{book,
author = {Vimes, Samuel},
title = {How To Be A Good Copper},
date = {2002}
}
end{filecontents}
usepackage[backend=biber,maxcitenames=1,maxbibnames=2,
giveninits=true]{biblatex}
bibliography{bib.bib}
% usepackage{xstring} % for if clause
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
usebibmacro{journal}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}, citeyear{#1}}}} % to get author, title, journal, year
begin{document}
Article:\ cfootcite{article}
Book:\ cfootcite{book}
end{document}
biblatex conditionals
biblatex conditionals
asked yesterday
Taunch
9810
9810
2
I strongly recommend not to build upcite
commands from othercite...
commands. Commands defined likecfootcite
usually can't deal with multiple citations (cfootcite{sigfridsson,nussbaum}
) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute severalcite...
-like macros at once. Commands like these are better defined withDeclareCiteCommand
. The additional advantage ofDeclareCiteCommand
for your case is that ...
– moewe
yesterday
2
... additional information about the entry is available directly (such as the entry type), which can be used to deal with conditional formatting for entry types directly. Note how Audrey's answer to tex.stackexchange.com/a/29931/35864 uses just oneDeclareCiteCommand
and declares everything within that one command.
– moewe
yesterday
@moewe Thanks for the recommendation, I had noticed that it was misbehaving when trying to cite multiple sources.
– Taunch
16 hours ago
add a comment |
2
I strongly recommend not to build upcite
commands from othercite...
commands. Commands defined likecfootcite
usually can't deal with multiple citations (cfootcite{sigfridsson,nussbaum}
) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute severalcite...
-like macros at once. Commands like these are better defined withDeclareCiteCommand
. The additional advantage ofDeclareCiteCommand
for your case is that ...
– moewe
yesterday
2
... additional information about the entry is available directly (such as the entry type), which can be used to deal with conditional formatting for entry types directly. Note how Audrey's answer to tex.stackexchange.com/a/29931/35864 uses just oneDeclareCiteCommand
and declares everything within that one command.
– moewe
yesterday
@moewe Thanks for the recommendation, I had noticed that it was misbehaving when trying to cite multiple sources.
– Taunch
16 hours ago
2
2
I strongly recommend not to build up
cite
commands from other cite...
commands. Commands defined like cfootcite
usually can't deal with multiple citations (cfootcite{sigfridsson,nussbaum}
) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute several cite...
-like macros at once. Commands like these are better defined with DeclareCiteCommand
. The additional advantage of DeclareCiteCommand
for your case is that ...– moewe
yesterday
I strongly recommend not to build up
cite
commands from other cite...
commands. Commands defined like cfootcite
usually can't deal with multiple citations (cfootcite{sigfridsson,nussbaum}
) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute several cite...
-like macros at once. Commands like these are better defined with DeclareCiteCommand
. The additional advantage of DeclareCiteCommand
for your case is that ...– moewe
yesterday
2
2
... additional information about the entry is available directly (such as the entry type), which can be used to deal with conditional formatting for entry types directly. Note how Audrey's answer to tex.stackexchange.com/a/29931/35864 uses just one
DeclareCiteCommand
and declares everything within that one command.– moewe
yesterday
... additional information about the entry is available directly (such as the entry type), which can be used to deal with conditional formatting for entry types directly. Note how Audrey's answer to tex.stackexchange.com/a/29931/35864 uses just one
DeclareCiteCommand
and declares everything within that one command.– moewe
yesterday
@moewe Thanks for the recommendation, I had noticed that it was misbehaving when trying to cite multiple sources.
– Taunch
16 hours ago
@moewe Thanks for the recommendation, I had noticed that it was misbehaving when trying to cite multiple sources.
– Taunch
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
You can use the biblatex
command
ifentrytypes{article}{usebibmacro{journal}addcommaaddspace}{}
in the definition of you auxiliary citejournal
cite command, and remove the comma after citejournal{#1}
.
Thus having
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
ifentrytype{article}{usebibmacro{journal}addcommaaddspace}{}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}citeyear{#1}}}}
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
You can use the biblatex
command
ifentrytypes{article}{usebibmacro{journal}addcommaaddspace}{}
in the definition of you auxiliary citejournal
cite command, and remove the comma after citejournal{#1}
.
Thus having
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
ifentrytype{article}{usebibmacro{journal}addcommaaddspace}{}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}citeyear{#1}}}}
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
add a comment |
up vote
2
down vote
You can use the biblatex
command
ifentrytypes{article}{usebibmacro{journal}addcommaaddspace}{}
in the definition of you auxiliary citejournal
cite command, and remove the comma after citejournal{#1}
.
Thus having
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
ifentrytype{article}{usebibmacro{journal}addcommaaddspace}{}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}citeyear{#1}}}}
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
add a comment |
up vote
2
down vote
up vote
2
down vote
You can use the biblatex
command
ifentrytypes{article}{usebibmacro{journal}addcommaaddspace}{}
in the definition of you auxiliary citejournal
cite command, and remove the comma after citejournal{#1}
.
Thus having
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
ifentrytype{article}{usebibmacro{journal}addcommaaddspace}{}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}citeyear{#1}}}}
You can use the biblatex
command
ifentrytypes{article}{usebibmacro{journal}addcommaaddspace}{}
in the definition of you auxiliary citejournal
cite command, and remove the comma after citejournal{#1}
.
Thus having
DeclareCiteCommand{citejournal}
{usebibmacro{prenote}}
{usebibmacro{citeindex}%
ifentrytype{article}{usebibmacro{journal}addcommaaddspace}{}}
{multicitedelim}
{usebibmacro{postnote}}
newcommand{cfootcite}[1]{
{tiny{citeauthor{#1}, citetitle{#1}, citejournal{#1}citeyear{#1}}}}
edited yesterday
answered yesterday
Guido
23.8k54785
23.8k54785
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
add a comment |
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
Thank you, this solves my problem. But how would you address the problem @moewe has pointed out in the above comment?
– Taunch
16 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461307%2fbiblatex-custom-citation-with-conditional-clause%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I strongly recommend not to build up
cite
commands from othercite...
commands. Commands defined likecfootcite
usually can't deal with multiple citations (cfootcite{sigfridsson,nussbaum}
) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute severalcite...
-like macros at once. Commands like these are better defined withDeclareCiteCommand
. The additional advantage ofDeclareCiteCommand
for your case is that ...– moewe
yesterday
2
... additional information about the entry is available directly (such as the entry type), which can be used to deal with conditional formatting for entry types directly. Note how Audrey's answer to tex.stackexchange.com/a/29931/35864 uses just one
DeclareCiteCommand
and declares everything within that one command.– moewe
yesterday
@moewe Thanks for the recommendation, I had noticed that it was misbehaving when trying to cite multiple sources.
– Taunch
16 hours ago