使用 Moderncv 和 renewenvironment 語句更改參考書目順序

使用 Moderncv 和 renewenvironment 語句更改參考書目順序

不久前,我從網路上複製並貼上了以下程式碼,以便對出版物進行分類。

現在我意識到出版順序與我在參考書目中定義的順序不符。我必須將哪個命令添加到\renewenvironment{thebibliography}區塊中,以便我的訂單未排序。簡單地設定參考書目樣式不適用於此自訂程式碼。

我嘗試過\renewcommand{\bibliographystyle}{\unsrt},但我對 LaTeX 很爛並且不知道我實際上在做什麼。

我正在使用multibibmoderncvOverleaf。

這是我的程式碼:

\makeatletter\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}\makeatother

\makeatletter
\renewenvironment{thebibliography}[1]%
  {%
    \subsection{\refname}%
    \small%
    \begin{list}{\bibliographyitemlabel}%
      {%
        \setlength{\topsep}{0pt}%
        \setlength{\labelwidth}{\hintscolumnwidth}%
        \setlength{\labelsep}{\separatorcolumnwidth}%
        \leftmargin\labelwidth%
        \advance\leftmargin\labelsep%
        \@openbib@code%
        \usecounter{enumiv}%
        \let\p@enumiv\@empty%
        \renewcommand\theenumiv{\@arabic\c@enumiv}}%
        \sloppy\clubpenalty4000\widowpenalty4000%
  }%
  {%
    \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
    \end{list}%
  }
\makeatother
\usepackage{multibib}
\newcites{journal,preprint,bthesis}{{Journals},{Technical Reports \& Pre-prints},{Bachelor Thesis}}

答案1

您沒有向我們展示可編譯的 MWE,因此我只是使用了一個較短的模板範例,您可以在 class 中找到moderncv,版本 2.0.0,當前版本。如果您使用的是較舊的版本,我建議您更新!或告訴我們您在問題中使用的版本。您也沒有向我們展示您如何以及以何種順序引用了哪些書目條目,也沒有向我們展示使用過的書目文件。下次請盡可能完整回答您的問題。

moderncv對於以下內容,我僅使用版本 2.0.0附帶的資料。

您可以在以下程式碼部分中看到引用和建構參考書目的相關部分:

%in your preamble:
\newcites{book,misc}{{Books},{Others}} % <==============================

% in your code:
% Publications from a BibTeX file using the multibib package
\section{Publications}
\nocitebook{book1,book2}
\bibliographystylebook{unsrt} % unsrt plain <=================================
\bibliographybook{publications}                   % 'publications' is the name of a BibTeX file
\nocitemisc{misc1,misc2,misc3}
\bibliographystylemisc{unsrt} % unsrt plain <=================================
\bibliographymisc{publications}                   % 'publications' is the name of a BibTeX file

命令\nocitebook{book1,book2}先引book1,然後book2。使用指令\bibliographystylebook{unsrt}您可以選擇參考書目樣式,在本例中unsrt,這表示依照用於引用的順序顯示參考書目中的參考書目條目。第二次也是一樣multibib,第三次你必須這樣做第三次multibib

使用multibib改變了通常的編譯鏈。對於上面的兩個 multibibs 顯示,您需要使用以下命令進行編譯:

  1. pdflatex mwe.tex,假設您的簡歷儲存在文件中mwe.tex。編譯履歷後,您將在同一目錄中找到book.aux兩個misc.aux檔案mwe.tex。在你的情況下,你應該找到三個文件journal.auxpreprint.auxbthesis.aux
  2. bibtex book建立第一個多參考書目。
  3. bibtex misc建立第二個參考書目。
  4. pdflatex mwe.tex像往常一樣兩次以獲得正確的頁碼、目錄等。

使用目前版本moderncv(2.0.0),您無需將該\renewenvironment{thebibliography}[1]%區塊複製到程式碼中。當然,您必須\newcites{journal,preprint,bthesis}{{Journals},{Technical Reports \& Pre-prints},{Bachelor Thesis}}在序言中定義您使用的 multibibs (正如我在本範例中對兩個 bib 檔案所做的那樣)。

publication.bib使用以下可編譯的 MWE(使用模板中的bib 檔案moderncv):

% pdflatex mwe.tex
% bibtex book
% bibtex misc
% pdflatex mwe.tex
% pdflatex mwe.tex
\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{casual}
\moderncvcolor{blue}

\usepackage[scale=0.75]{geometry}

\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{example-image-golden-upright}
\quote{Some quote}

\setlength{\footskip}{70pt}

\makeatletter
\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}
\makeatother

\usepackage{multibib}
\newcites{book,misc}{{Books},{Others}} % <==============================


\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

\section{Extra 2}
\cvlistdoubleitem{Item 1}{Item 4}
\cvlistdoubleitem{Item 2}{Item 5\cite{book1}}
\cvlistdoubleitem{Item 3}{Item 6. Like item 3 in the single column list before, this item is particularly long to wrap over several lines.}

\section{References}
\begin{cvcolumns}
  \cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
  \cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
  \cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textbf{those} also (all available upon request).}
\end{cvcolumns}

% Publications from a BibTeX file using the multibib package
\section{Publications}
\nocitebook{book1,book2}
\bibliographystylebook{unsrt} % unsrt plain <=================================
\bibliographybook{publications}                   % 'publications' is the name of a BibTeX file
\nocitemisc{misc1,misc2,misc3}
\bibliographystylemisc{unsrt} % unsrt plain <=================================
\bibliographymisc{publications}                   % 'publications' is the name of a BibTeX file

\end{document}

你得到結果:

由此產生的參考書目

為了確保您可以在此處測試我給定的 MWE,範例圍兜檔案publication.bib

%% start of file `publications.bib'.
%% Copyright 2006-2012 Xavier Danaux (xdanaux at gmail.com).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.


@BOOK{book1,
  author = {John Doe and Author 1},
  title = {Title},
  publisher = {Publisher},
  edition = {edition},
  year = {year},
}

@BOOK{book2,
  author = {John Doe and Author 2},
  title = {Title},
  publisher = {Publisher},
  edition = {edition},
  year = {year},
}

@MISC{misc1,
  author = {John Doe},
  title = {Title},
  year = {year},
}

@MISC{misc2,
  author = {John Doe and Author 3},
  title = {Title},
  year = {year},
}

@MISC{misc3,
  author = {John Doe},
  title = {Title},
  year = {year},
}


%% end of file `publications.bib'.

相關內容