Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I use \bibitem style bibliography in LyX without the ERT? Right now I prepare the @article style bibliography in a file (say) references.bib. Then I go: Insert => List/TOC => BibTeX Bibliography and simply add that file to my LyX document. But this is too time-consuming. I simply want to borrow references from another document which uses \bibtem.

Example of one of the references:

  \bibitem [{\citenamefont {Schnyder}\ \emph {et~al.}(2008)\citenamefont
  {Schnyder}, \citenamefont {Ryu}, \citenamefont {Furusaki},\ and\
  \citenamefont {Ludwig}}]{schnyder2008}%
  \BibitemOpen
  \bibfield  {author} {\bibinfo {author} {\bibnamefont {Schnyder} \bibfnamefont
  {A.~P.}}, \bibinfo {author} {\bibfnamefont {S.}~\bibnamefont {Ryu}}, \bibinfo
  {author} {\bibfnamefont {A.}~\bibnamefont {Furusaki}}, \ and\ \bibinfo
  {author} {\bibfnamefont {A.~W.~W.}\ \bibnamefont {Ludwig}}} (\bibinfo {year}
  {2008}),\ \href@noop {} {\bibfield  {journal} {\bibinfo  {journal} {Phys.
  Rev. B},\ }\textbf {\bibinfo {volume} {78}},\ \bibinfo {pages}
  {195125}}\BibitemShut {NoStop}%
share|improve this question
add comment

2 Answers

To add a bibliography environment in LyX, choose Bibliography from the top-left drop down menu:

enter image description here

share|improve this answer
    
That's good to know. Can't believe I never noticed this option in the drop down menu. But the problem is that it simply outputs the text I enter after (say) key-1[1]. It does not recognize the code for \bibitem –  PhHEP Dec 27 '12 at 18:09
    
@PhHEP I'm sorry, I don't fully understand. Do you want to copy references from a LaTeX file, and be able to use the referencing system in LyX? In that case I think you have to place the code in the \bibitem in an ERT. So after the key-x[x], add an ERT and paste the code. –  Torbjørn T. Dec 27 '12 at 23:34
    
Yes, I have a latex file which has more than 300 references. So I simply want to be able to copy-paste those 300 references into my LyX file and be able to reference them using: Insert => Citation... Like I said in the beginning of my post, I want a way of doing this without the ERT. If I paste those 300 references in the ERT then I will also have to cite them (in the main text) using ERT; I don't want this. Also, if I use your suggestion of adding ERT after the key-x[x] then I would have to add the 300 references one by one. That defeats the purpose. –  PhHEP Dec 28 '12 at 0:20
    
@PhHEP Of course, I see. Sorry, I was unable to understand your problem from your description of it. –  Torbjørn T. Dec 28 '12 at 9:52
add comment

Import the LaTeX document with the references in LyX (menu File → Import, then copy and paste the references to your Lyx document. If some key already exists it will be renamed.

If there are problems to importing the Latex file, first clean the LaTeX document as munch as possible, that is:

\documentclass{article}
\begin{document}
\begin{thebibliography}{}
\bibitem{Smith} Bla bla bla ...
\bibitem{Chaves} Bla bla bla ...
....
\end{thebibliography}
\end{document}

Note that references in the original .tex file must be \bibitem[label ]{key}plain text. If there special commands inside the references, then you need the packages and\or macros defining these commands of the original document. Consider this example:

\documentclass{article}
% \usepackage{natbib}          % uncomment to activate 
% \newcommand{\bibinfo}[1]{ }  % uncomment to activate
\begin{document}
\begin{thebibliography}{}
\bibitem[Geek, 2012]{Geek2012}
  \bibinfo{author}{X.~van~der Geek}, 
  \bibinfo{title}{Too complicated bibliography},
  \bibinfo{journal}{J. Fake. Ex.} 
  \bibinfo{volume}{13}
  (\bibinfo{year}{2012}) 
  \bibinfo{pages}{21--39}.
\end{thebibliography}
\end{document}

This file do not work with pdflatex (is not a problem of LyX) because \bibinfo commands are undefined control sequences, unless you uncomment in the preamble the call to package natbib or alternatively to the macro of the next line (that do nothing except defining the command).

With one of these modifications, Lyx can import a working document, but still have no idea of what \bibinfo is, so it is imported as a ERT.

BTW, your example look a much more complicated .bbl file generated by BibTeX, not a handwritten \bibitems list of a .tex file. In order to compile it with pdflatex, as I do not know the right package for some commands, I made this settings in the preamble:

\documentclass{article}
\usepackage{natbib}
\usepackage{hyperref}
\newcommand*{\citenamefont}[1]{#1}
\newcommand*{\bibnamefont}[1]{#1}
\newcommand*{\bibfnamefont}[1]{#1}
% \newcommand*{\bibinfo}[1]{ } % not needed with natbib
% \newcommand*{\bibfield}[1]{ } % not needed with natbib
% \newcommand*{\BibitemOpen}[1]{ } % not needed with natbib
% \newcommand*{\BibitemShut}[1]{ }% not needed with natbib
% \newcommand{\bibinfo}[1]{ } % not needed with natbib
\begin{document}
\begin{thebibliography}{9}

\bibitem [{\citenamefont {Schnyder}\ \emph {et~al.}(2008)\citenamefont {Schnyder}, \citenamefont {Ryu}, \citenamefont {Furusaki},\ and\ \citenamefont {Ludwig}}]{schnyder2008}% 
\BibitemOpen
\bibfield {author} 
{\bibinfo{author} {\bibnamefont {Schnyder} \bibfnamefont {A.~P.}}, 
\bibinfo {author} {\bibfnamefont {S.}~\bibnamefont {Ryu}}, 
\bibinfo {author} {\bibfnamefont {A.}~\bibnamefont {Furusaki}}, \ and\ 
\bibinfo {author} {\bibfnamefont {A.~W.~W.}\ 
\bibnamefont {Ludwig}}} 
(\bibinfo {year} {2008}),
\ \href@noop {} 
{\bibfield {journal} 
{\bibinfo {journal} {Phys. Rev. B},\ }
\textbf {\bibinfo {volume} {78}},\ 
\bibinfo {pages} {195125}}
\BibitemShut {NoStop}%
\end{thebibliography}
\end{document}

This work with pdflatex, but Lyx cannot import correctly (beside many ERT boxes, cannot produce a PDF).

So, without a .bib file available and with so many references, the best solution could be remove all (or most)the commands with search & replace, except \bibitem, and then import the cleaned version.

share|improve this answer
    
That was a very good suggestion. This partially worked! Please refer to the edit in the original post to understand the problem better. Everything after the "\BibitemOpen" started giving trouble in the imported LyX file. Everything before that was sitting in a nice grey field. It seems the LyX document recognized the code only up to "\BibitemOpen". As a result, I can cite a reference from the main text without ERT. So that's one problem solved! But I cannot compile it because it does not recognize anything after "\BibitemOpen" –  PhHEP Dec 28 '12 at 2:00
    
@PhHEP, I updated the answer –  Fran Dec 28 '12 at 6:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.