首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LaTeX中的书目要么有错误的数字,要么参考是错误的。我怎么才能解决这个问题?

LaTeX中的书目要么有错误的数字,要么参考是错误的。我怎么才能解决这个问题?
EN

Stack Overflow用户
提问于 2022-10-07 16:34:44
回答 1查看 94关注 0票数 1

我的LaTeX文档有问题。它要么打印出源代码章节的错误页码(版本1),要么跳转到错误的页面(版本2)。(下面是最小可重现性示例)

Version 1:每当我单击“扫盲者”时,它跳到前一章而不是我想要的章节,但至少它会在我的目录中打印出正确的页码。

代码语言:javascript
复制
\newpage
\setstretch{1.5}
\fancypagestyle{plain}{
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries Literatur}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\pagestyle{plain}
\addcontentsline{toc}{chapter}{Literatur}
\printbibliography

Version 2:每当我单击“扫盲者”时,它跳到正确的章节,但它在我的目录中打印出错误的页码。它不打印本章的第一个页码,而是打印最后一个页码。

代码语言:javascript
复制
\newpage
\setstretch{1.5}
\fancypagestyle{plain}{
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries Literatur}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\pagestyle{plain}
\printbibliography
\addcontentsline{toc}{chapter}{Literatur}

我已经尝试过在每一行中添加\幻影段和\清除双页,但它们似乎不起作用。

如果它是重要的,这是我使用的类:

代码语言:javascript
复制
\documentclass[fontsize=11pt,paper=a4,oneside,toc=listof,listof=totocnumbered,ngerman]{scrreprt}

而且我不能在\打印书目之前改变课程或者所有的东西,因为这是我所在的大学的模板。我也不能手动添加所有的源(我在一些答案中见过这个),因为我有200多个源。

我很感谢你能提供的任何帮助,因为我的想法快用完了,我必须尽快发表论文!:)

最小可重现性示例

bibliography.bib路径:内容/bib/书目

代码语言:javascript
复制
@misc{a,
 author = {a},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{b,
 author = {b},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{c,
 author = {c},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{d,
 author = {d},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{e,
 author = {e},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{f,
 author = {f},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{g,
 author = {g},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{h,
 author = {h},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{i,
 author = {i},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{j,
 author = {j},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

main.tex (第1版)

代码语言:javascript
复制
\documentclass[fontsize=11pt,paper=a4,oneside,toc=listof,listof=totocnumbered,ngerman]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[babel,german=guillemets]{csquotes}

\usepackage[sfdefault]{FiraSans}
\usepackage[T1]{fontenc}
\renewcommand*\oldstylenums[1]{{\firaoldstyle #1}}

%SPACING
\usepackage{setspace}
\setstretch{1,3}

%PAGE SETUP
\usepackage{pdflscape}
%margins
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=20mm]{geometry}
%header footer
\usepackage{fancyhdr} % header field
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries \thechapter \hspace{0.5em}\leftmark}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}
}

%BIBLIOGRAPHY
\usepackage{bibgerm}
\usepackage[sortcites,style=numeric,sorting=none,backend=biber]{biblatex}
\IfFileExists{content/bib/bibliography_final.bib}
    {\bibliography{content/bib/bibliography_final.bib}}%
    {%
        \IfFileExists{content/bib/bibliography.bib}%
            {\bibliography{content/bib/bibliography.bib}}%
            {%
                \typeout{bibliography not found, using empty!}%
                \bibliography{content/bib/empty.bib}%
            }%
    }%


%HYPERLINKS BOOKMARKS
\usepackage{hyperref} %Links
\hypersetup{colorlinks =false,linkbordercolor = {0 0 0},linktoc = all,pdfborder = {0 0 0},bookmarksdepth = subsection,bookmarksnumbered = true}
\urlstyle{same}
\usepackage[]{bookmark}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

\tableofcontents

\chapter{Chapter}

Text \cite{a,b,c,d,e,f,g,h,i,j}

\section{Section}

More text

\newpage
\setstretch{1.5}
 \fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries Literatur}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\pagestyle{plain}
\addcontentsline{toc}{chapter}{Literatur}
\printbibliography

\end{document}

main.tex (第2版)

代码语言:javascript
复制
\documentclass[fontsize=11pt,paper=a4,oneside,toc=listof,listof=totocnumbered,ngerman]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[babel,german=guillemets]{csquotes}

\usepackage[sfdefault]{FiraSans}
\usepackage[T1]{fontenc}
\renewcommand*\oldstylenums[1]{{\firaoldstyle #1}}

%SPACING
\usepackage{setspace}
\setstretch{1,3}

%PAGE SETUP
\usepackage{pdflscape}
%margins
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=20mm]{geometry}
%header footer
\usepackage{fancyhdr} % header field
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries \thechapter \hspace{0.5em}\leftmark}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}
}

%BIBLIOGRAPHY
\usepackage{bibgerm}
\usepackage[sortcites,style=numeric,sorting=none,backend=biber]{biblatex}
\IfFileExists{content/bib/bibliography_final.bib}
    {\bibliography{content/bib/bibliography_final.bib}}%
    {%
        \IfFileExists{content/bib/bibliography.bib}%
            {\bibliography{content/bib/bibliography.bib}}%
            {%
                \typeout{bibliography not found, using empty!}%
                \bibliography{content/bib/empty.bib}%
            }%
    }%


%HYPERLINKS BOOKMARKS
\usepackage{hyperref} %Links
\hypersetup{colorlinks =false,linkbordercolor = {0 0 0},linktoc = all,pdfborder = {0 0 0},bookmarksdepth = subsection,bookmarksnumbered = true}
\urlstyle{same}
\usepackage[]{bookmark}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

\tableofcontents

\chapter{Chapter}

Text \cite{a,b,c,d,e,f,g,h,i,j}

\section{Section}

More text

\newpage
\setstretch{1.5}
 \fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries Literatur}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\pagestyle{plain}
\printbibliography
\addcontentsline{toc}{chapter}{Literatur}

\end{document}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-07 21:25:08

您可以在\phantomsection行之前使用\addcontentsline{toc}{chapter}{Literatur}来提供它可以跳转到的内容。

还请注意,用于添加bib文件的biblatex语法是\addbibressource而不是\bibliography

代码语言:javascript
复制
\documentclass[fontsize=11pt,paper=a4,oneside,toc=listof,listof=totocnumbered,ngerman]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[babel,german=guillemets]{csquotes}

\usepackage[sfdefault]{FiraSans}
\usepackage[T1]{fontenc}
\renewcommand*\oldstylenums[1]{{\firaoldstyle #1}}

%SPACING
\usepackage{setspace}
\setstretch{1,3}

%PAGE SETUP
\usepackage{pdflscape}
%margins
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=20mm]{geometry}
%header footer
\usepackage{fancyhdr} % header field
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries \thechapter \hspace{0.5em}\leftmark}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}
}


\begin{filecontents*}[overwrite]{\jobname.bib}
@misc{a,
 author = {a},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{b,
 author = {b},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{c,
 author = {c},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{d,
 author = {d},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{e,
 author = {e},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{f,
 author = {f},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{g,
 author = {g},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{h,
 author = {h},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{i,
 author = {i},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

@misc{j,
 author = {j},
 title = {asdfs},
 url = {https://stackoverflow.com/questions/73990151/bibliography-in-latex-either-has-a-wrong-number-or-reference-is-wrong-how-can-i?noredirect=1#comment130644039_73990151}
}

\end{filecontents*}


%BIBLIOGRAPHY
\usepackage{bibgerm}
\usepackage[sortcites,style=numeric,sorting=none,backend=biber]{biblatex}
\addbibresource{\jobname.bib}


%HYPERLINKS BOOKMARKS
\usepackage{hyperref} %Links
\hypersetup{colorlinks =false,linkbordercolor = {0 0 0},linktoc = all,pdfborder = {0 0 0},bookmarksdepth = subsection,bookmarksnumbered = true}
\urlstyle{same}
\usepackage[]{bookmark}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

\tableofcontents

\chapter{Chapter}

Text \cite{a,b,c,d,e,f,g,h,i,j}

\section{Section}

More text

\newpage
\setstretch{1.5}
 \fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\normalsize \bfseries \thepage}
\fancyhead[L]{\normalsize \bfseries Literatur}
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0pt}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\pagestyle{plain}
\phantomsection
\addcontentsline{toc}{chapter}{Literatur}
\printbibliography

\end{document}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73990151

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档