【问题标题】:Automatically extract a bibitem in LaTex在 LaTex 中自动提取一个 bibitem
【发布时间】:2022-02-11 01:20:56
【问题描述】:

我正在撰写一篇会议论文,其中要求我使用格式 \bibitem 条目而不是 BibTeX 文件作为参考文献。谷歌学术支持 BibTeX。有没有自动提取\bibitem的方法或工具?

示例: 我有 BibTeX 格式的参考文献如下:

 @article{rieck2011similarity,
  title={Similarity measures for sequential data},
  author={Rieck, Konrad},
  journal={Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery},
  volume={1},
  number={4},
  pages={296--304},
  year={2011},
  publisher={Wiley Online Library}
}

我想将 BibTeX 格式转换为以下格式(\bibitem):

\bibitem{rieck2011similarity} K.~Rieck, \emph{Similarity measures for sequential data},\hskip 1em plus 0.5em minus 0.4em\relax Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery, 2011.

【问题讨论】:

  • 您能更具体地说明您想要什么吗?也就是说,展示你目前拥有的东西,以及你想要发生的事情。
  • @Werner 请在上述问题中找到更新。
  • 也许这个tex.stackexchange.com/questions/124874/…可以帮到你。

标签: latex


【解决方案1】:

由于没有其他答案,这种(不是完全自动的)方式可能会有所帮助:

  • 在 BibTeX 中使用您的参考书目创建一个 *.tex 文件
  • 照常编译(latex/bibtex/latex)
  • 在*.tex文件目录下,打开*.bbl:所有引用都转换成bibitem。
  • 复制/粘贴到您的文档中

来源:http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2005-10/msg00552.html

【讨论】:

    【解决方案2】:

    我创建了这个online bibtex converter,所以它可以将你的 BibTeX 文本或文件转换为 bibitem。

    示例

     @article{rieck2011similarity,
      title={Similarity measures for sequential data},
      author={Rieck, Konrad},
      journal={Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery},
      volume={1},
      number={4},
      pages={296--304},
      year={2011},
      publisher={Wiley Online Library}
    }
    
    

    BibItem 输出

    \bibitem{rieck2011similarity}Rieck, K. Similarity measures for sequential data. {\em Wiley Interdisciplinary Reviews: Data Mining And Knowledge Discovery}. \textbf{1}, 296--304 (2011)
    

    【讨论】:

      【解决方案3】:

      嗯,我用这个matlab函数,自动一一转换,比较容易搞定。可以从GitHub下载,matlab函数如下。

      function [bibitem] = bibtex2bibitem(bibtexpath)
      path = bibtexpath;
      cells = importdata(path);
      A = string(cells);
      n = length(cells);
      K_name = strings(n,1);
      citecode = extractBetween(A(1),'{',',');
      
      for i = 2:1:n-1
              rawleft = extractBefore(A(i),'=');
              K_name(i) = strtrim(rawleft);
      
      %--------------------------------------------------------------------
              if strcmp(K_name(i),"author")
                  SVacI(1) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      author = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      author = strtrim(extractBetween(A(i),'=',','));
                  end 
      
      %--------------------------------------------------------------------         
              elseif strcmp(K_name(i),"title")
                  SVacI(2) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      title = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      title = strtrim(extractBetween(A(i),'=',','));
                  end 
      
      %--------------------------------------------------------------------
              elseif strcmp(K_name(i),"journal")
                  SVacI(3) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      journal = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      journal = strtrim(extractBetween(A(i),'=',','));
                  end 
      
      %--------------------------------------------------------------------
              elseif strcmp(K_name(i),"volume")
                  SVacI(4) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      volume = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      volume = strtrim(extractBetween(A(i),'=',','));
                  end
      
      %--------------------------------------------------------------------
              elseif (strcmp(K_name(i),"number"))||(strcmp(K_name(i),"issue"))
                  SVacI(5) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      number = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      number = strtrim(extractBetween(A(i),'=',','));
                  end
      
      %--------------------------------------------------------------------
              elseif strcmp(K_name(i),"pages")
                  SVacI(6) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      pages = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      pages = strtrim(extractBetween(A(i),'=',','));
                  end
      
      %--------------------------------------------------------------------
              elseif strcmp(K_name(i),"month")
                  SVacI(7) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      month = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      month = strtrim(extractBetween(A(i),'=',','));
                  end
      
      %--------------------------------------------------------------------
              elseif strcmp(K_name(i),"year")
                  SVacI(8) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      year = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      year = strtrim(extractBetween(A(i),'=',','));
                  end
      
      %--------------------------------------------------------------------
              elseif strcmp(K_name(i),"publisher")
                  SVacI(9) = 1;
                  rawright = extractAfter(A(i),'=');
                  ccb = regexp(rawright,'}');     % ccb = [check curly bracket]
                  if (ccb~=0)
                      publisher = strtrim(extractBetween(A(i),'{','}'));
                  else 
                      publisher = strtrim(extractBetween(A(i),'=',','));
                  end           
      
      %--------------------------------------------------------------------
              else
                  msg = join(["Sorry!","[", K_name(i), "]","is not being handled by the program."]);
                  disp(msg)
              end
      end
      
      %--------------------------------------------------------------------
      %               @-> Style reference term code varifications. 
      %                  msg = join(["author","=",SVacI(1);...
      %                              "title","=",SVacI(2);...
      %                              "journal","=",SVacI(3);...
      %                              "volume","=",SVacI(4);...
      %                              "number","=",SVacI(5);...
      %                              "pages","=",SVacI(6);...
      %                              "month","=",SVacI(7);...
      %                              "year","=",SVacI(8);...
      %                              "publisher","=",SVacI(9)]);
      %                              disp(SVacI)
      
                    if all(SVacI(1)==0)||(SVacI(2)==0)||(SVacI(3)==0)||(SVacI(8)==0)
                        bibitem = sprintf('THE ARTICLE IS NOT CORRECT. THE AUTHOR, TITLE, JOURNAL AND YEAR SECTIONS ARE COMPULSORY! PLEASE INCLUDE THEM AND RE-RUN THE SOFTWARE:)');
                    elseif all(SVacI == [1    1   1   0   0   0   0   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/},(%s).',citecode,author,title,journal,year);
                    elseif all(SVacI == [1    1   1   0   0   0   0   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/},(%s). %s.\n',citecode,author,title,journal,year,publisher);
                    elseif all(SVacI == [1    1   1   0   0   0   1   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/},(%s %s).',citecode,author,title,journal,month,year);
                    elseif all(SVacI == [1    1   1   0   0   0   1   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/},(%s %s). %s.',citecode,author,title,journal,month,year,publisher);
                    elseif all(SVacI == [1    1   1   0   0   1   0   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, %s,(%s).',citecode,author,title,journal,pages,year);
                    elseif all(SVacI == [1    1   1   0   0   1   0   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, %s,(%s). %s.',citecode,author,title,journal,pages,year,publisher);
                    elseif all(SVacI == [1    1   1   0   0   1   1   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, %s,(%s %s).',citecode,author,title,journal,pages,month,year);
                    elseif all(SVacI == [1    1   1   0   0   1   1   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, %s,(%s %s). %s.',citecode,author,title,journal,pages,month,year,publisher);
                    elseif all(SVacI == [1    1   1   0   1   0   0   1   0])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s,(%s).',citecode,author,title,journal,number,year);
                    elseif all(SVacI == [1    1   1   0   1   0   0   1   1])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s,(%s). %s.',citecode,author,title,journal,number,year,publisher);
                    elseif all(SVacI == [1    1   1   0   1   0   1   1   0])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s,(%s %s).',citecode,author,title,journal,number,month,year);
                    elseif all(SVacI == [1    1   1   0   1   0   1   1   1])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s,(%s %s). %s.',citecode,author,title,journal,number,month,year,publisher);
                    elseif all(SVacI == [1    1   1   0   1   1   0   1   0])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s, %s,(%s).',citecode,author,title,journal,number,pages,year);
                    elseif all(SVacI == [1    1   1   0   1   1   0   1   1])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s, %s,(%s). %s.',citecode,author,title,journal,number,pages,year,publisher);
                    elseif all(SVacI == [1    1   1   0   1   1   1   1   0])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s, %s,(%s %s).',citecode,author,title,journal,number,pages,month,year);
                    elseif all(SVacI == [1    1   1   0   1   1   1   1   1])
                        disp("Attention! THE VOLUME HAS TO BE ASSOCIATED WITH NUMBER, PLEASE CHECK!") 
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, No.~%s, %s,(%s %s). %s.',citecode,author,title,journal,number,pages,month,year,publisher);
                    elseif all(SVacI == [1    1   1   1   1   0   0   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s,(%s).',citecode,author,title,journal,volume,number,year);
                    elseif all(SVacI == [1    1   1   1   1   0   0   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s,(%s). %s.',citecode,author,title,journal,volume,number,year,publisher);
                    elseif all(SVacI == [1    1   1   1   1   0   1   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s,(%s %s).',citecode,author,title,journal,volume,number,month,year);
                    elseif all(SVacI == [1    1   1   1   1   0   1   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s,(%s %s). %s.',citecode,author,title,journal,volume,number,month,year,publisher);
                    elseif all(SVacI == [1    1   1   1   1   1   0   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s, %s,(%s).',citecode,author,title,journal,volume,number,pages,year);
                    elseif all(SVacI == [1    1   1   1   1   1   0   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s, %s,(%s). %s.',citecode,author,title,journal,volume,number,pages,year,publisher);
                    elseif all(SVacI == [1    1   1   1   1   1   1   1   0])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s, %s,(%s %s).',citecode,author,title,journal,volume,number,pages,month,year);
                    elseif all(SVacI == [1    1   1   1   1   1   1   1   1])
                        bibitem = sprintf('\\bibitem{%s} %s,``%s," {\\it %s\\/}, Vol.~%s, No.~%s, %s,(%s %s). %s.',citecode,author,title,journal,volume,number,pages,month,year,publisher);
                    end 
                    clipboard('copy',bibitem);
                    disp('The bibitem has been copied to the clipboard!')
      end 
      

      示例输入:

      @article{hamid1969microwave,
        title={Microwave pasteurization of raw milk},
        author={Hamid, MAK and Boulanger, RJ and Tong, SC and Gallop, RA and Pereira, RR},
        journal={Journal of Microwave Power},
        volume={4},
        number={4},
        pages={272--275},
        year={1969},
        publisher={Taylor \& Francis}
      }
      
      Sample Output: 
      
      '\bibitem{hamid1969microwave} Hamid, MAK and Boulanger, RJ and Tong, SC and Gallop, RA and Pereira, RR,``Microwave pasteurization of raw milk," {\it Journal of Microwave Power\/}, Vol.~4, No.~4, 272--275,(1969). Taylor \& Francis.'
      

      【讨论】:

      • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
      • 现在,matlab函数已经激活,可以稳定使用了。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      • 2022-12-22
      • 1970-01-01
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      相关资源
      最近更新 更多