moderncv と renewenvironment ステートメントを使用して参考文献の順序を変更する

moderncv と renewenvironment ステートメントを使用して参考文献の順序を変更する

少し前に、出版物を分類するために、インターネットから次のコードをコピーして貼り付けました。

出版順序が参考文献で定義した順序と一致していないことに気付きました。\renewenvironment{thebibliography}順序がソートされないようにするには、どのコマンドをブロックに追加する必要がありますか。このカスタマイズされたコードでは、単に bibliographystyle を設定するだけでは機能しません。

試してみました\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 が示されていなかったため、moderncv現在のバージョン 2.0.0 のクラスで見つかる短いテンプレート例を使用しました。古いバージョンを使用している場合は、更新することをお勧めします。または、質問で使用しているバージョンを教えてください。また、どの bib エントリをどの順序でどのように引用したか、使用した bib ファイルを示していませんでした。次回は、質問をできるだけ完全なものにしてください。

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は、引用に使用した順序で参考文献の bib エントリを表示することを意味します。 2 番目についても同じでmultibib、3 番目の についても同じ操作を 3 回行う必要がありますmultibib

multibib通常のコンパイル チェーンを変更して使用します。上記の 2 つの multibibs では、次のようにコンパイルする必要があります。

  1. pdflatex mwe.tex、あなたの履歴書はファイル に保存されていると仮定しますmwe.tex。履歴書をコンパイルするとbook.aux、 とmisc.aux同じディレクトリに と の2 つのファイルが見つかります。あなたの場合は、と の3mwe.texつのファイルが見つかるはずですjournal.auxpreprint.auxbthesis.aux
  2. bibtex book最初のマルチ書誌目録を構築します。
  3. bibtex misc2番目の参考文献を作成します。
  4. pdflatex mwe.tex通常どおり、適切なページ番号、目次などを取得するには 2 回実行します。

現在のバージョンmoderncv(2.0.0)では\renewenvironment{thebibliography}[1]%、ブロックをコードにコピーする必要はありません。 もちろん、使用するマルチビブを\newcites{journal,preprint,bthesis}{{Journals},{Technical Reports \& Pre-prints},{Bachelor Thesis}}プリアンブル内で定義する必要があります (この例では 2 つの bib ファイルに対して行いました)。

次のコンパイル可能な MWE (テンプレートpublication.bibの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}

結果は次のようになります:

結果として得られた参考文献

確実にテストするには、ここにあるサンプル bib ファイルで私の 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'.

関連情報