convert bib file to \bibitem[\protect\citeauthoryear - latex

I have a reference file (bib file) I want to convert it as
\bibitem[\protect\citeauthoryear{Allen C.W.}{1973}] {b1} Allen C.W., 1973,
Astrophysical quantities, ${3^{rd}}$ ed. (Athlone Press, London)
when I use
\nocite{*}
\bibliographystyle{apalike}
\bibliography{bibfile}
Output ppl file as
\bibitem[Allen, 1973]{allen1973astrophysical}
Allen, C.~W. (1973).

Combining natbib with the newapa style gives something similar:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
#BOOK{1973asqu.book.....A,
author = {{Allen}, C.~W.},
title = "{Astrophysical quantities}",
keywords = {ASTROPHYSICS, ASTRONOMICAL CONSTANTS, TABLES, HANDBOOKS},
booktitle = {London: University of London, Athlone Press, |c1973, 3rd ed.},
year = 1973,
adsurl = {https://ui.adsabs.harvard.edu/abs/1973asqu.book.....A},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
\end{filecontents*}
\usepackage{natbib}
\begin{document}
\cite{1973asqu.book.....A}
\bibliographystyle{newapa}
\bibliography{\jobname}
\end{document}
Resulting .bbl file:
\begin{thebibliography}{}
\bibitem[\protect\citeauthoryear{{Allen}}{{Allen}}{1973}]{1973asqu.book.....A}
{Allen}, C.~W. (1973).
\newblock {\em {Astrophysical quantities}}.
\end{thebibliography}

Related

How to underline specific author name automatically in LaTex bibiolgraphy

For a CV, I want to underline my name wherever it appears in a bibliography. I am using LaTex with biblatex. Is there an easy way to automatically underline a certain name? Thanks!
For example, I want "Name Surname" to be underlined automatically in all the entries in the bibliography.
\documentclass[12pt]{article}
\usepackage[maxbibnames=99, sorting=ydnt]{biblatex}
\addbibresource{test.bib}
\begin{filecontents}{test.bib}
#article{paper1,
author = {Surname, Name and Another, Name and Thethird, Name and Andthe, Last},
journal = {JUR},
month = {5},
title = {{Title very good}},
year = {2015}
}
#article{paper2,
author = {Guy, Some and Surname, Name and Dude, The},
journal = {JUR},
month = {5},
title = {{Another brilliant title}},
year = {2016},
}
\end{filecontents}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
You can use the trick from https://tex.stackexchange.com/a/355317/36296
\documentclass[12pt]{article}
\usepackage[maxbibnames=99, sorting=ydnt]{biblatex}
\begin{filecontents*}[overwrite]{\jobname.bib}
#article{paper1,
author = {Surname, Name and Another, Name and Thethird, Name and Andthe, Last},
journal = {JUR},
month = {5},
title = {{Title very good}},
year = {2015}
}
#article{paper2,
author = {Guy, Some and Surname, Name and Dude, The},
journal = {JUR},
month = {5},
title = {{Another brilliant title}},
year = {2016},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\usepackage{xstring}
\usepackage{etoolbox}
\newboolean{bold}
\newcommand{\makeauthorsbold}[1]{%
\DeclareNameFormat{author}{%
\setboolean{bold}{false}%
\renewcommand{\do}[1]{\expandafter\ifstrequal\expandafter{\namepartfamily}{####1}{\setboolean{bold}{true}}{}}%
\docsvlist{#1}%
\ifthenelse{\value{listcount}=1}
{%
{\expandafter\ifthenelse{\boolean{bold}}{\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}{\namepartfamily\addcomma\addspace \namepartgiveni}}%
}{\ifnumless{\value{listcount}}{\value{liststop}}
{\expandafter\ifthenelse{\boolean{bold}}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}%
{\expandafter\ifthenelse{\boolean{bold}}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}%
}
\ifthenelse{\value{listcount}<\value{liststop}}
{\addcomma\space}{}
}
}
\makeauthorsbold{Surname, Name}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Just to be sure, do you want to highlight all the authors or just a particular name?
In the first case, I invite you to look at the .bst files that format the bibliography to find the one that suits you or even create one yourself (which is quite long).
In the second case, I don't see any solution except to add \hl{Name, Surname} inside your bib file.

Cite author and title for monographs

for a university paper I have to write an essay. The professor has percise instructions how to cite. For monograph books, he wants the author and the title in the footnotes.
I tried to use biblatex for this, but could not manage to get it to work
My minimal reproducible example is:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{test}
\usepackage[style=authoryear,maxcitenames=2,maxbibnames=99, uniquename=false]{biblatex}
\addbibresource{references.bib}
\setcounter{biburlnumpenalty}{100}
\setcounter{biburlucpenalty}{100}
\setcounter{biburllcpenalty}{100}
\DefineBibliographyStrings{ngerman}{
andothers = {{et\,al\adddot}},
}
\DeclareNameAlias{sortname}{family-given}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{#1\isdot}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\begin{document}
\maketitle
\section{Introduction}
This is a minimal reproducible example. \footcite{adams1995hitchhiker}
\printbibliography
\end{document}
which outputs:
footnote image
Now i want to add the title of the book too (in this case The Hitchhiker's Guide to the Galaxy) in the footnote
Any idea how to implement this?
It sounds as if the authortitle style would be closer to your requirements:
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{test}
\usepackage[style=authortitle,maxcitenames=2,maxbibnames=99, uniquename=false]{biblatex}
\begin{filecontents*}[overwrite]{\jobname.bib}
#book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\setcounter{biburlnumpenalty}{100}
\setcounter{biburlucpenalty}{100}
\setcounter{biburllcpenalty}{100}
\DefineBibliographyStrings{ngerman}{
andothers = {{et\,al\adddot}},
}
\DeclareNameAlias{sortname}{family-given}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{#1\isdot}
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\begin{document}
\maketitle
\section{Introduction}
This is a minimal reproducible example. \footcite{knuth}
\printbibliography
\end{document}

Bibliography style and line breaks in Beamer-poster

I'm making a poster through beamer and found a problem with my bibliography style. I want my references to use the full horizontal space available in the poster, like:
(1) Authors. Title. Journal.
But instead of that, every reference get breaked in 3 lines as:
(1) Authors
Title
Journal
Example
Here's the bibliography code I've been using:
\begin{block}{References}
\small
\bibliographystyle{sbc}
\bibliography{referencias.bib}
\end{block}
The line breaks can be avoided by setting the bibliography templates like this:
\setbeamertemplate{bibliography entry article}{}
\setbeamertemplate{bibliography entry title}{}
\setbeamertemplate{bibliography entry location}{}
\setbeamertemplate{bibliography entry note}{}
MWE:
\documentclass{beamer}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
#book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
\end{filecontents*}
\setbeamertemplate{bibliography entry article}{}
\setbeamertemplate{bibliography entry title}{}
\setbeamertemplate{bibliography entry location}{}
\setbeamertemplate{bibliography entry note}{}
\begin{document}
\begin{frame}
\cite{knuth}
\begin{block}{References}
\small
\bibliographystyle{plain}
\bibliography{\jobname}
\end{block}
\end{frame}
\end{document}

duplication of same citation in a slide with \footcite{} in Beamer

I am using class beamer to prepare scientific presentation. The myrefernces.bib is included using \addbibresource{}. In one slide, one citation is used twice using \footcite{}. The same citation appears twice in the bottom of the slide also with different numbers. How to avoid this and make the citation appear with same number in the slide as well as through out presentation to avoid confusion.
Thanks in advance.
manual workaround:
\documentclass{beamer}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
#book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\begin{frame}
test\footcite{knuth}
test\footnotemark[1]
\end{frame}
\end{document}

How can I have LaTeX print citations inside of parentheses?

I have a problem with reference style in LaTeX.
I use:
\usepackage[backend=bibtex,style=authoryear]{biblatex} %
But when I look at the references, the text is not inside parentheses.
For example:
,reviewed in Roy et al. 2010
should be
,reviewed in (Roy et al. 2010)
All bibliography package have a mean to either add or not parenthesis to a citation, depending on context.
Indeed, generally it is undesirable to have all citations bracketted.
For instance, if you say "see \cite{foobar}", you probably want "see (Foobar 1999)". But in a phrase like "(\cite{foobar} also has interesting examples)", you do not want parenthesis, as "((Foobar 1999) also ...)" looks ugly and is not advised in standard typographic rules. Probably "(Foobar 1999 also has ...)" is prefered.
For this reason, in vanilla bibtex, you have \cite (without parenthesis) and \citep (with parenthesis).
In biblatex, you can do the same. Instead of using \cite, use \parencite to get citations with parenthesis.
Another approach to add parenthesis around the citations is to change the definition of the \cite macro:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
#book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
#article{einstein,
author = {Einstein, A.},
title = {Die Grundlage der allgemeinen Relativitätstheorie},
journal = {Annalen der Physik},
volume = {354},
number = {7},
doi = {10.1002/andp.19163540702},
pages = {769--822},
year = {1916}
}
\end{filecontents*}
\usepackage[backend=bibtex,style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\DeclareCiteCommand{\cite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand*{\cite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
\cite{einstein}
\printbibliography
\end{document}

Resources