【问题标题】:Latex using foreign language results in error in citations使用外语的乳胶导致引用错误
【发布时间】:2019-06-30 15:58:10
【问题描述】:

当包含 LaTeX 外语包时:

\usepackage[utf8x]{inputenc}
\usepackage[english,hebrew]{babel}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}

引用错误:

例子:

Missing number, treated as zero.

<to be read again> 
                   \afterassignment 
l.19 ...{example1}}}{\@@number {27}}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

另一个例子:

Improper alphabetic constant.

<to be read again> 
                   \afterassignment 
l.86 ...15normalized}. \citet{example2}
                                                   further improved the resu...
A one-character control sequence belongs after a ` mark.
So I'm essentially inserting \0 here.

! Missing = inserted for \ifnum.
<to be read again> 
                   \afterassignment 
l.86 ...15normalized}. \citet{example2}
                                                   further improved the resu...
I was expecting to see `<', `=', or `>'. Didn't.

而且引文是空的。 当我不包括外语包时,我不会收到错误,并且引用很棒。

我用于引用的格式是 \usepackage{natbib} 和文档 \documentclass[12pt,twoside]{mitthesis}。

我也尝试了其他格式并得到相同的错误。

bibliography.bib 是传统的:

@article{example1,
  title={Title1},
  author={Author},
  journal={arXiv preprint arXiv:1706.04902},
  year={2019}
}

@article{example2,
  title={Title2},
  author={Author},
  journal={arXiv preprint arXiv:1706.04902},
  year={2019}
}

Minimal Working Example 是超级基础的,(最小的 Not-Working Example 是当你取消注释希伯来语部分时):

\documentclass{report}
%\documentclass[12pt,twoside]{mitthesis}
\usepackage{natbib}

% Hebrew
% \usepackage[utf8x]{inputenc}
% \usepackage[english,hebrew]{babel}
% \usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}

\begin{document}
%\selectlanguage{english}
\include{introduction} %some text with \cite{example1} and so on...


% bibliography
\bibliography{bibliography}
\bibliographystyle{plainnat}

\end{document}

【问题讨论】:

  • 您能否完成您的代码 sn-p 以便可编译?您能否将围兜条目 example1 和 example2 添加到您的问题中?
  • @NoaYehezkel 你能加个minimal working example with bibliography (MWEB)吗?
  • @NoaYehezkel 不幸的是我的水晶球不见了。您能否制作一个不依赖我们没有的外部文件的 MWEB?例如。 bibliography.tex的内容是什么?
  • 另请注意,您使用的类已过时
  • 当使用 \documentclass{report} 我得到同样的错误......我编辑了 MWEB 以使其更简单。

标签: latex


【解决方案1】:

为了避免在babel 之后加载natbib 的问题:

\documentclass{report}
%\documentclass[12pt,twoside]{mitthesis}


% Hebrew
\usepackage[utf8]{inputenc}
\usepackage[english,hebrew]{babel}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}
\usepackage{natbib}

\begin{filecontents}{bibliography.bib}
@article{example1,
  title={Title1},
  author={Author},
  journal={arXiv preprint arXiv:1706.04902},
  year={2019}
}

@article{example2,
  title={Title2},
  author={Author},
  journal={arXiv preprint arXiv:1706.04902},
  year={2019}
}
\end{filecontents}

\begin{document}
% \selectlanguage{english}
\cite{example1,example2}

{
\selectlanguage{english}
\cite{example1,example2}
}

% bibliography
% \selectlanguage{english}
\bibliography{bibliography}
\bibliographystyle{plainnat}

 \selectlanguage{english}
\bibliography{bibliography}
\bibliographystyle{plainnat}

\end{document}

https://www.overleaf.com/read/kgrzpznmzjcz

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    相关资源
    最近更新 更多