auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select and insert multiple bibliography entries into one \cite comma


From: Vladimir Lomov
Subject: Re: Select and insert multiple bibliography entries into one \cite command with regexp search.
Date: Thu, 12 Aug 2021 10:20:50 +0800

Hello,
** Hongyi Zhao <hongyi.zhao@gmail.com> [2021-08-11 12:42:28 +0800]:

Okay, let's try to clarify situation and to sort out different errors.

> On Wed, Aug 11, 2021 at 10:43 AM Vladimir Lomov <lomov.vl@yandex.ru> wrote:

[...]

>> Besides, this in NOT an ERROR! This is a WARNING! You should look into
>> reftex-docstruct-symbol.blg file to figure out what the problem is.

> The content of the above file is as follows:

> $ cat reftex-docstruct-symbol.blg
> This is BibTeX, Version 0.99d (TeX Live 2021)
> Capacity: max_strings=200000, hash_size=200000, hash_prime=170003
> The top-level auxiliary file: reftex-docstruct-symbol.aux
> I found no \bibdata command---while reading file reftex-docstruct-symbol.aux
> I found no \bibstyle command---while reading file reftex-docstruct-symbol.aux
> You've used 1 entry,
>             0 wiz_defined-function locations,
>             85 strings with 610 characters,
> and the built_in function-call counts, 0 in all, are:
> = -- 0
> > -- 0
> < -- 0
> + -- 0
> - -- 0
> * -- 0
> := -- 0
> add.period$ -- 0
> call.type$ -- 0
> change.case$ -- 0
> chr.to.int$ -- 0
> cite$ -- 0
> duplicate$ -- 0
> empty$ -- 0
> format.name$ -- 0
> if$ -- 0
> int.to.chr$ -- 0
> int.to.str$ -- 0
> missing$ -- 0
> newline$ -- 0
> num.names$ -- 0
> pop$ -- 0
> preamble$ -- 0
> purify$ -- 0
> quote$ -- 0
> skip$ -- 0
> stack$ -- 0
> substring$ -- 0
> swap$ -- 0
> text.length$ -- 0
> text.prefix$ -- 0
> top$ -- 0
> type$ -- 0
> warning$ -- 0
> while$ -- 0
> width$ -- 0
> write$ -- 0
> (There were 2 error messages)

To get the same output I had to make third example document

%%% doc-samp3.ltx
------------------------------------------------------------------------------
\documentclass{article}

\usepackage{natbib}

\begin{document}

Sample text, a citation, \cite{test4:2021aug} without any information about
it.

\begin{verbatim}
(insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
\end{verbatim}

NO CITATIONS!!!

% \bibliographystyle{plainnat}
% \bibliography{sample.bib}
% \bibliography{/home/vladimir/tmp/test/emacs/sample2.bib}

\end{document}

%%% Local Variables:
%%% TeX-master: t
%%% End:
------------------------------------------------------------------------------

As you can see I try to add citation (test4:2021aug) but do not provide any
information about that "reference". No wonder that bibtex warned me about
missing '\bibdata' command (you may found that in that case running 'C-c ['
would give message in minibuffer: "No valid bibliography..."; evaluating
verbatim block wouldn't have 'bib' part).

Let's compare the 'doc-samp3.ltx' document with following 'doc-samp.ltx' and
'doc-samp2.ltx' ones:

%%% doc-samp.ltx
------------------------------------------------------------------------------
\documentclass{article}

\usepackage{natbib}

\begin{document}

Sample text. Cite: \cite{test:2021aug}.

\begin{verbatim}
(insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
\end{verbatim}

Another cite: \cite{test2:2021aug}.

\bibliographystyle{plainnat}
% \bibliography{sample.bib}
\bibliography{/home/vladimir/tmp/test/emacs/sample.bib}

\end{document}

%%% Local Variables:
%%% TeX-master: t
%%% End:
------------------------------------------------------------------------------

%%% doc-samp2.ltx
------------------------------------------------------------------------------
\documentclass{article}

\usepackage{natbib}

\begin{document}

Sample text. Cite: \cite{test:2021aug}.

\begin{verbatim}
(insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
\end{verbatim}

Another cite: \cite{test2:2021aug}.

\bibliographystyle{plainnat}
% \bibliography{sample.bib}
\bibliography{/home/vladimir/tmp/test/emacs/sample2.bib}

\end{document}

%%% Local Variables:
%%% TeX-master: t
%%% End:
------------------------------------------------------------------------------

The first document, 'doc-samp.ltx', cites some works and sets bibliography
style (cp. with your "I found no '\bibstyle'" from blg file). Neither
Emacs(+AUCTeX) nor (pdf)latex+bibtex would issue any warnings, document is
typeset fine.

The second document, 'doc-samp2.ltx', refers to a file that don't exist, so
bibtex warns you and exited with error. You'll see the warning in minibuffer
and excerpt from blg if run 'C-c C-l'.

What would be correct way to check if something goes wrong:
- make small complete example, like first document which cites some work, sets
  bibliography file with necessary information and bibliography style;
- process it with latex engine and bibtex, check output (either in Emacs or
  just look into blg file), just look for error(s).

If you do something weird, for example, citing a work but DO NOT PROVIDING
bibliography information, latex as well as Emacs couldn't help you.  It
(latex) sees you want to cite something but it couldn't "expand" that into
meaningful piece of text. The second document exactly shows that: if document
refers to a file that don't exist bibtex will complain.

What Arash was asking was another thing: he wanted to know if Emacs "knows"
about the bibtex file, i.e. if it could parse your document, see the
'\bibliography' command and could read it. The second document shows that if
there is no such file Emacs(+AUCTeX+RefTeX) do not have 'bib' part.

[...]

>>
>> I open the document in Emacs (with my configuration of 
>> AUCTeX+RefTeX+CDLaTeX),
>> did the same thing as Arash and got[1]
>>
>> ------------------------------------------------------------------------------
>> (bib "/home/vladimir/tmp/test/sample.bib")
>> ------------------------------------------------------------------------------

> To be  sure, how to eval the form in the verbatim env?

Ahh, I thought it might be unclear but didn't ask. Emacs allows you to
"evaluate" any part of buffer as Emacs Lisp code (see, e.g., "Operating on the
Region" in Emacs manual), even code on a line (see "27.9 Evaluating Emacs Lisp
Expressions") running "C-x C-e" on the line.

> I try to eval the following in *scratch* buffer with `C-j', but obtain 
> `nilnil':

> (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))

> nilnil

Do this in the buffer with open document.

>> Of course I was able to typeset the document within Emacs as well as on
>> command line. Also I could insert new \cite using RefTeX 'C-c [' key as well
>> as to add new items into it while point being in '\cite' macro but I didn't
>> test to input several citations at one time.

> Your example works for me as well. By hitting 'C-c [' key, the `SELECT
> THE CITATATION FORMAT' frame will be triggered as shown in the
> attachment. But I still can't figure out how to select the first
> format listed on the frame, i.e. the following:

> [^M] \cite [][]{%l}

> Which is the ^M key?

Enter key, also bound to 'C-j'.

> And based on my further testing, the 'C-c [' also works with
> `\string~' expansio to find the bib file, as shown in the attachment
> titled by `my-original-exmaple.png'. I don't know why it doesn't work
> with 'C-c [' previously.

[...]

>> [1] To be honest when I open document first time in Emacs I got 'nil'. To get
>> correct result I had to run either 'Ref -> Parse Document -> Entire Document'
>> or to try insert citation using 'C-u C-c [' which forces document parsing. 
>> The
>> necessary information is written to .rel file.

> Without using the above trick, only `C-c [' will work on my side with your
> example. OTOH, even I run the above step, I still can't find the .rel file.

The .rel file was part of my configuration. I tried again and it works as you
wrote.

> Best, Hongyi

---
WBR, Vladimir Lomov

-- 
Never ask two questions in a business letter.  The reply will discuss
the one you are least interested, and say nothing about the other.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]