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: Wed, 11 Aug 2021 10:43:56 +0800

Hello,
** Hongyi Zhao <hongyi.zhao@gmail.com> [2021-08-11 07:47:33 +0800]:

> On Wed, Aug 11, 2021 at 12:40 AM Arash Esbati <arash@gnu.org> wrote:
[...]
>>
>> For me, it works with a simple file like this on my Windows box:
>>
>>     \documentclass{article}
>>
>>     \usepackage{natbib}
>>     \bibliography{z:/path/to/test-bib-file}
>>
>>     \begin{document}
>>
>>     \begin{verbatim}
>>     (insert "\n"
>>             (format "%S" (symbol-value reftex-docstruct-symbol)))
>>     \end{verbatim}
>>     \end{document}
>>
>>     %%% Local Variables:
>>     %%% mode: latex
>>     %%% TeX-master: t
>>     %%% End:
>>
>> When I eval the form in the verbatim env, there is an entry like this:
>>
>>     (bib "z:/path/to/test-bib-file.bib")
>>
>> inserted in the buffer, hence RefTeX finds the file which is in a
>> different directory than the .tex file.

> I tried to adjust your above example according to my situation as follows:

> \documentclass{article}

> \usepackage{natbib}
> \bibliography{/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib}

> \begin{document}


> \cite{weiFirstprinciplesCharacterizationBibased2009}

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

> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:

> Then I run xelatex and bibtex several times on the above document

but that's not what Arash did! He explicitly wrote:

>> When I eval the form in the verbatim env, there is an entry like this:

and shown the output. What you get when do the same?

> in Emacs, but finally meet the following error:

> ##################
> Running `LaTeX' on `reftex-docstruct-symbol' with ``xelatex
> -file-line-error   --synctex=1 -interaction=nonstopmode
> reftex-docstruct-symbol.tex''
> This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021)
> (preloaded format=xelatex)
>  restricted \write18 enabled.
> entering extended mode
> (./reftex-docstruct-symbol.tex
> LaTeX2e <2020-10-01> patch level 4
> L3 programming layer <2021-05-07>
> (/opt/texlive/2021/texmf-dist/tex/latex/base/article.cls
> Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
> (/opt/texlive/2021/texmf-dist/tex/latex/base/size10.clo))
> (/opt/texlive/2021/texmf-dist/tex/latex/natbib/natbib.sty)
> \bibdata{/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib}
> (./reftex-docstruct-symbol.bbl)
> (/opt/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
> (|extractbb --version)) (./reftex-docstruct-symbol.aux)
> (/opt/texlive/2021/texmf-dist/tex/latex/base/ts1cmr.fd)

> Package natbib Warning: Citation
> `weiFirstprinciplesCharacterizationBibased2009' on page 1 undefined on
> input line 9.


> Package natbib Warning: There were undefined citations.

> [1] (./reftex-docstruct-symbol.aux) )
> Output written on reftex-docstruct-symbol.pdf (1 page).
> SyncTeX written on reftex-docstruct-symbol.synctex.gz.
> Transcript written on reftex-docstruct-symbol.log.

> TeX Output finished at Wed Aug 11 07:43:44
> ##################

And how this suppose to be related with RefTeX? You run xelatex (you didn't
mention earlier that you typeset document using a LaTeX engine) and then
bibtex. Whether you typeset document using AUCTeX or did this on command line
isn't really matter.

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. Usually if
there is a problem AUCTeX (in minibuffer) suggest to run 'C-c C-l' to see
the log.

[...]

>> Since the absolute path version doesn't work, you could try something
>> else provided by RefTeX.  Otherwise you have to find the culprit in your
>> setup.  I don't think this is a RefTeX issue.

> Thank you for your comment.

I've made following example:

------------------------------------------------------------------------------
\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/sample.bib}

\end{document}

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

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")
------------------------------------------------------------------------------

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.

The second example has only one minor change: the name of bibtex file.

------------------------------------------------------------------------------
\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/sample2.bib}

\end{document}

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

Now there is no such bibtex file and there is no 'bib' part. And as expected
bibtex exits "abnormally" with errors (you could see them in Emacs if run 'C-c
C-l'):

------------------------------------------------------------------------------
Running `BibTeX' on `doc-sample2' with ``bibtex doc-sample2.aux''
This is BibTeX, Version 0.99d (TeX Live 2021)
The top-level auxiliary file: doc-sample2.aux
The style file: plainnat.bst
I couldn't open database file /home/vladimir/tmp/test/sample2.bib
---line 5 of file doc-sample2.aux
 : \bibdata{/home/vladimir/tmp/test/sample2.bib
 :                                             }
I'm skipping whatever remains of this command
I found no database files---while reading file doc-sample2.aux
Warning--I didn't find a database entry for "test:2021aug"
Warning--I didn't find a database entry for "test2:2021aug"
(There were 2 error messages)

TeX Output exited abnormally with code 2 at Wed Aug 11 09:31:05
------------------------------------------------------------------------------

It would be helpful if you say what exactly you do and what you expect and
didn't try to ask several unrelated questions in the same topic. Also, follow
advices given on the mailing list and tell what exactly you run and what you
get.

I've made following bib file for tests:

------------------------------------------------------------------------------
@article{test:2021aug,
  title   = "{Some thought about testing and how people read the answers}",
  author  = "Lomov V.P.",
  journal = "Philosophical Thoughts",
  year    = "2021",
  vol     = "08",
  pages   = "133–135"
}

@article{test2:2021aug,
  title   = "{Why sometimes we got angry while reading some replies on mailing 
lists?}",
  author  = "Lomov V.P.",
  journal = "Philosophical Thoughts",
  year    = "2021",
  vol     = "08",
  pages   = "143–144"
}

@article{test3:2021aug,
  title   = "{How to calm down yourself when replying to someone}",
  author  = "Lomov V.P.",
  journal = "Philosophical Thoughts",
  year    = "2021",
  vol     = "08",
  pages   = "150–151"
}
------------------------------------------------------------------------------

--- NOTES ---

[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.

> Best, Hongyi

---
WBR, Vladimir Lomov

-- 
Winning isn't everything, but losing isn't anything.

Attachment: signature.asc
Description: PGP signature


reply via email to

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