문서에서 bibtex 번호 매기기를 사용자 정의하는 방법은 무엇입니까?

문서에서 bibtex 번호 매기기를 사용자 정의하는 방법은 무엇입니까?

BibTeX 참조가 포함된 간단한 LaTeX 문서가 있습니다.

\documentclass[12pt]{article}
\begin{document}
 
\section{First section}
 
This document is an example of \texttt{thebibliography} environment using 
in bibliography management. Three items are cited: \textit{The \LaTeX\ Companion} 
book \cite{latexcompanion}, the Einstein journal paper \cite{einstein}, and the 
Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are
\cite{latexcompanion,knuthwebsite}. 
 
\medskip
\bibliographystyle{unsrt}
\bibliography{sample}
 
\end{document}

이것의 출력은 다음과 같습니다.

여기에 이미지 설명을 입력하세요

본문과 참고문헌 섹션의 참고문헌 번호를 내가 선택한 특정 번호로 변경하고 싶습니다. 어떻게 해야 하나요?

다음과 같은 것을 갖고 싶다고 가정해 보겠습니다.

1 첫 번째 섹션

본 문서는 참고문헌 관리에 사용되는 참고문헌 환경의 예시입니다. 세 가지 항목이 인용되었습니다: The LATEX Companion book[11], Einstein 저널 논문[22], Donald Knuth의 웹사이트[33]. LATEX 관련 항목은 [11, 33]이다.

참고자료

[11] 미셸 구센스(Michel Goossens), 프랭크 미텔바흐(Frank Mittelbach), 알렉산더 사마린(Alexander Samarin). LATEX 동반자. 애디슨-웨슬리, 매사추세츠 레딩, 1993년.

[22] 알베르트 아인슈타인. Zur Elektrodynamik bewegter Korper. (독일어) [움직이는 물체의 전기역학에 대하여]. Annalen der Physik, 322(10):891{921, 1905.

[33] 도널드 크누스. Knuth: 컴퓨터와 조판.

LaTeX와 BibTeX로 이 작업을 수행할 수 있나요?

답변1

먼저 일반적인 방법으로 참고문헌을 준비할 수 있습니다. 그런 다음 %%START과 사이에 코드를 추가하여 아래 표시된 방식으로 원하는 숫자를 설정할 수 있습니다 %%END.

환경은 filecontents예시용으로만 사용되었으며 자체 데이터베이스를 사용하십시오.

\begin{filecontents}{\jobname.bib}
@book{Knuth1984texbook,
    Author = {Knuth, D.E.},
    Title = {The \TeX book, volume A of Computers and typesetting},
    Publisher = {Addison-Wesley},
    Year = {1984},
}
@book{Chomsky1957,
    Address = {The Hague},
    Author = {Noam Chomsky},
    Publisher = {Mouton},
    Title = {Syntactic Structures},
    Year = {1957},
}
@book{Chomsky1965,
    Address = {Cambridge Mass.},
    Author = {Noam Chomsky},
    Publisher = {MIT Press},
    Title = {Aspects of the Theory of Syntax},
    Year = {1965},
}
\end{filecontents}

\documentclass{article}
\usepackage{xpatch} % also loads expl3

%%START
\makeatletter
\xpatchcmd{\@bibitem}
  {\item}
  {\item[\@biblabel{\changekey{#1}}]}
  {}{}
\xpatchcmd{\@bibitem}
  {\the\value{\@listctr}}
  {\changekey{#1}}
  {}{}
\makeatother

\ExplSyntaxOn
\cs_new:Npn \changekey #1
 {
  \str_case:nVF {#1} \g_changekey_list_tl { ?? }
 }
\cs_new_protected:Npn \setchangekey #1 #2
 {
  \tl_gput_right:Nn \g_changekey_list_tl { {#1}{#2} }
 }
\tl_new:N \g_changekey_list_tl
\cs_generate_variant:Nn \str_case:nnF { nV }
\ExplSyntaxOff

\setchangekey{Knuth1984texbook}{9}
\setchangekey{Chomsky1957}{3}
\setchangekey{Chomsky1965}{7}
%%END

\begin{document}
\section{First section}

This document is an example of \texttt{thebibliography} environment using 
 bibliography management. Three items are cited: \emph{Syntactic Structures} 
book \cite{Chomsky1957}, \emph{Aspects} \cite{Chomsky1965}, and  
Donald Knuth's \TeX book \cite{Knuth1984texbook}.

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

여기에 이미지 설명을 입력하세요

단지 게으름 때문에 Alan Munn과 동일한 데이터를 사용했습니다.

답변2

다음은 제가 제안한 솔루션 버전입니다. 이것의 제한된 사용을 고려하면 아마도 솔루션을 더 정교하게 만드는 것은 가치가 없을 것입니다. 참조의 기본 구문은 다음과 같습니다.

\mycite{<number>}{<bib-key>}

이미 사용된 인용( 로 시작)을 참조하려면 \mycite간단히 를 사용하면 됩니다 \ref{<bib=key}.

\mybib그런 다음 각 항목에 대한 를 사용하여 실제 참고문헌 항목을 소개합니다 . 이는 명령에 사용한 번호와 함께 나타나며 \mycite, 환경에 입력한 순서대로 나타납니다 itemize.

\begin{filecontents}{\jobname.bib}

@book{Knuth1984texbook,
    Author = {Knuth, D.E.},
    Title = {The TEXbook, volume A of Computers and typesetting},
    Year = {1984}}

@book{Chomsky1957,
    Address = {The Hague},
    Author = {Noam Chomsky},
    Publisher = {Mouton},
    Title = {Syntactic Structures},
    Year = {1957}}

@book{Chomsky1965,
    Address = {Cambridge Mass.},
    Author = {Noam Chomsky},
    Publisher = {{MIT} Press},
    Title = {Aspects of the Theory of Syntax},
    Year = {1965}}
\end{filecontents}
\documentclass[12pt]{article}
\usepackage{natbib}
\usepackage{calc}
\usepackage{etoolbox}
\usepackage{bibentry}
\usepackage{enumitem}
\SetLabelAlign{bibright}{\hss\llap{[#1]}}
\newcounter{mynum}
\newcommand\mycite[2]{[#1]\setcounter{mynum}{0}\addtocounter{mynum}{#1-1}\refstepcounter{mynum}\label{#2}}
\newcommand\mybib[1]{\item[\ref{#1}]\bibentry{#1}}

\begin{document}
\section{First section}

This document is an example of \texttt{thebibliography} environment using 
 bibliography management. Three items are cited: \emph{Syntactic Structures} 
book \mycite{6}{Chomsky1957}, \emph{Aspects} \mycite{4}{Chomsky1965}, and  
Donald Knuth's TeXBook \mycite{10}{Knuth1984texbook}. The Linguistics related items are
[\ref{Chomsky1965},\ref{Chomsky1957}].
\medskip
\bibliographystyle{unsrtnat}
\nobibliography{\jobname}
\begin{itemize}[labelwidth=!,labelsep=1em,align=bibright]
\mybib{Chomsky1957}
\mybib{Chomsky1965}
\mybib{Knuth1984texbook}
\end{itemize}
\end{document}

코드 출력

답변3

귀하의 의견을 읽은 후에는 더 쉬운 방법이 있다고 생각합니다. nice 패키지가 있습니다. xcite이를 통해 다른 문서에서 인용을 가져올 수 있으며 숫자에 대해 걱정할 필요가 없습니다(다음 예에서는 다른 문서가 다음과 같다고 가정합니다). 라고 불리는 document.tex):

\documentclass{article}

\usepackage{xcite}
\externalcitedocument{document}

\begin{document}

\cite{knuth}


\end{document}

답변4

문제는 실제로 bib 데이터베이스의 항목에 사용자 정의 레이블을 사용하는 것에 관한 것이므로 Biblatex를 사용하여 이를 수행하는 표준 방법이 있다는 점을 추가하고 싶습니다. 간단히 데이터 필드를 사용하십시오.속기, 이는 데이터베이스의 해당 항목에 대한 표준 약칭을 재정의합니다. 다음의 최소 작업 예제에서는 문자를 몇 개 넣었지만, 물론 숫자나 원하는 것을 넣을 수도 있습니다.

\begin{filecontents}{thebib.bib}
@article{Boll,
author = {Boll, Grodan},
title = {Frogs now and then},
year = 1995,
journal = {Allers},
volume = 3,
shorthand = {FN\&T}
}
\end{filecontents}
\documentclass{article}
\usepackage{biblatex}
\addbibresource{thebib.bib}
\begin{document}
Frogs are common, see also \cite{Boll}.
\printbibliography
\end{document}

이것은 출력을 제공합니다 PDF 파일의 스크린샷

관련 정보