3

I have a file called Test.tex containting

ID1

I'm trying to feed this file to a \textcite{} command, using the input{}command.

\begin{filecontents*}{References.bib}
@article{ID1,
    Author = {Some Author},
    Journal = {Some Journal},
    Title = {Some Title},
    Year = {2016},
    Volume = {1(1)},
    Pages = {1-10}}
\end{filecontents*}
\documentclass{article}
\usepackage{catchfile}
\usepackage[style=authoryear]{biblatex}
\addbibresource{References.bib}
\begin{document}
\textcite{\input{./Test.tex}}
\printbibliography
\end{document}

Running this gives me the following error:

! Argument of \blx@citeargs@i has an extra }.
<inserted text> 
                \par 
l.15 ^^I\textcite{\input{./Test.tex}}

Looking at this thread, I tried going around the problem by using

\begin{filecontents*}{References.bib}
@article{ID1,
    Author = {Some Author},
    Journal = {Some Journal},
    Title = {Some Title},
    Year = {2016},
    Volume = {1(1)},
    Pages = {1-10}}
\end{filecontents*}
\documentclass{article}
\usepackage{catchfile}
\usepackage[style=authoryear]{biblatex}
\addbibresource{References.bib}
\begin{document}
\CatchFileDef\filecontent{Test.tex}{}
\expandafter\textcite\expandafter{\filecontent}
\printbibliography
\end{document}

This didn't completely solve my problem though. The reference list came out alright, but the in text citation just read ID1 instead of Author (2016).

4
  • Why do you want to rread a bibkey from a file?
    – Johannes_B
    Jul 21, 2016 at 16:52
  • @Johannes_B This is just a made up example (that's smaller for clarity). In reality, "Test.txt" contains a couple of hundred references that should be included using the \nocite command.
    – Speldosa
    Jul 21, 2016 at 16:55
  • Extract the needed entries in a separate file and use \nocite{*}, or create a set and cite that.
    – Johannes_B
    Jul 21, 2016 at 16:57
  • @Johannes_B Doing something like that seems like quite a mess to me. See: tex.stackexchange.com/questions/170316/…
    – Speldosa
    Jul 21, 2016 at 17:58

1 Answer 1

3

You're forgetting to say \endlinechar=-1. If you look in the log file, you'll find

LaTeX Warning: Citation 'ID1 ' on page 1 undefined on input line 23.

that accounts for the problem, due to the space added at the end of the line. With \endlinechar=-1, no end-of-line character is added.

In the example I used \jobname not to clobber my files.

\begin{filecontents*}{\jobname.bib}
@article{ID1,
    Author = {Some Author},
    Journal = {Some Journal},
    Title = {Some Title},
    Year = {2016},
    Volume = {1(1)},
    Pages = {1-10}}
\end{filecontents*}
\begin{filecontents*}{\jobname.key}
ID1
\end{filecontents*}

\documentclass{article}
\usepackage{catchfile}
\usepackage[style=authoryear]{biblatex}

\addbibresource{\jobname.bib}

\begin{document}

\CatchFileDef\filecontent{\jobname.key}{\endlinechar=-1 }
\textcite{\filecontent}

\printbibliography

\end{document}

Note that \expandafter is not needed.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .