2

I would like to set a custom biber command via AuCTeX's local variables. Consider the following example:

\documentclass{article}  
\begin{document}  
  hello world  
\end{document}      
%%% Local Variables:   
%%% mode: latex  
%%% TeX-master: t  
%%% LaTeX-command: "pdflatex -synctex=-1 -aux-directory auto %s"   
%%% BibTeX-command: "biber --bblsafechars ./auto/%s.bcf"  
%%% End:   

When I open it, emacs warns me about the "risky" command redefinitions. The LaTeX-command does get redefined, but the BibTeX one doesn't.

I assume it has something to do with the preset commands: In the Custumize Auctex -> TeX command -> TeX command list, I have

%`%l%(mode)%' %t 

for LaTeX, but

bibtex %s

for BibTeX. But I don't really understand the sytax of the first command, so I don't know how to change the second.

UPDATE

I have tried various other local variables, so that at this point my file looks like this:

\documentclass{article}  
\usepackage[backend=biber]{biblatex} 
\begin{document}  
  hello world  
\end{document}      
%%% Local Variables:   
%%% mode: latex  
%%% TeX-master: t  
%%% LaTeX-command: "pdflatex -synctex=-1 -aux-directory auto %s"   
%%% TeX-run-Biber: "biber --bblsafechars ./auto/%s"
%%% TeX-run-BibTeX: "biber --bblsafechars ./auto/%s"
%%% biber-command: "biber --bblsafechars ./auto/%s"
%%% BibTeX-command: "biber --bblsafechars ./auto/%s"
%%% TeX-command-Biber: "biber --bblsafechars ./auto/%s"
%%% LaTeX-biblatex-use-Biber:t
%%% End: 

Still, invoking either biber or BibTeX (via C-c C-c) runs the command without the options (both bblsafechars and the directory are ignored). On opening, emacs stil warns me about unsafe or risky options.

Presumably there's something I don't understand about how emacs chooses the actual command string, but I can't seem to really find out what.

3 Answers 3

1

AUCTeX doesn't have a direct interface to add arguments to the Biber entry in TeX-command-list. Hence, you have to manipulate the variable itself. You want to keep the change local to your file, so you have to go through an extra step.

I suggest you write a function and put something like this in your init file:

(eval-after-load "tex"
  '(defun my/biber-command-with-args ()
     "Replace Biber command in `TeX-command-list' with args."
     (make-local-variable 'TeX-command-list)
     (setq my/TeX-command-list (copy-alist TeX-command-list))
     (setq my/TeX-command-list
           (assq-delete-all
            (car (assoc "Biber" my/TeX-command-list))
            my/TeX-command-list))
     (add-to-list 'my/TeX-command-list
                  '("Biber" "biber --bblsafechars ./auto/%s.bcf"
                    TeX-run-Biber nil t
                    :help "Run Biber with args")
                  t)
     (setq TeX-command-list my/TeX-command-list)))

Now you can activate the function with a file local variable like this:

\documentclass{article}  
\begin{document}  
hello world 
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% LaTeX-biblatex-use-Biber: t
%%% eval: (my/biber-command-with-args)
%%% End:
2
  • Thanks! Iwouldn't have guessed that... (I had to change the thing you add to the command list to ("Biber-auto" "biber --bblsafechars ./auto/%s.bcf" TeX-run-command nil t :help "Run BibTeX with args"), then it worked.)
    – user104694
    Nov 9, 2017 at 8:20
  • @Toffomat - Yes, the "Biber" key in the list was missing. See my updated answer. Thanks for catching this. Nov 9, 2017 at 12:25
1

I cannot run biber on my computer, so my answers are rather suggestions. Anyway, looks like there is no defined Biber-command. I read AucTeX doc and tried C-h k C-c C-c. From what I read :

  • To have biber as a default command, you should add

    %%%LaTeX-biblatex-use-Biber:t

  • I would try to set the TeX-run-Biber command, but I am not very familiar with local configurations. Maybe

    %%%TeX-run-Biber: "biber --bblsafechars ./auto/%s.bcf"

will help?

3
  • Unfortunately, that doesn't help (and neither does setting TeX-command-Biber). C-h vtells me that the variable is locally set, but running biber or bibtex stil uses the default comand.
    – user104694
    Nov 1, 2017 at 8:16
  • @Toffomat. Which variable is locally set ? LaTeX-biblatex-use-Biber or TeX-run-Biber ? If TeX-run-Biber is unset, you may try with the setq syntax from your .emacs. I would also try ./auto/%s', since the bibtex function uses %s` as its default. I couldn't figure out exactly what does %s stand for in the doc.
    – sztruks
    Nov 1, 2017 at 15:54
  • I've updated the question and tried to clarify
    – user104694
    Nov 7, 2017 at 15:27
0

As of Emacs 29.1 (and probably earlier versions), there is an easier way than using the answer given by @arash-esbati:

  1. Customize the variable TeX-command-list
  2. Change the Command field of the Biber entry to how you want AUCTeX to invoke biber. In my case I added --validate-datamodel right after biber.
  3. Press the Apply and Save button.

You must log in to answer this question.

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