1

When I extend my code into a small example.
My tex code is:

\documentclass[a4paper,11pt]{article}
\usepackage{mathrsfs}
\usepackage{latexsym}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage[usenames]{color}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathrsfs}
\usepackage{dsfont}
\usepackage{indentfirst}

\newcommand\D{\tilde{\Delta}}
\newcommand\dr{\mathrm{d}}
\newcommand\Dr{\mathrm{D}}
\newcommand\pa{\partial}
\newcommand\aro{\alpha\rho}
\newcommand\hlf{\frac{1}{2}}
\newcommand\me{\mathrm{e}}
\newcommand\axi{\alpha\xi}
\newcommand\thf{h_{hf}}
\newcommand\Si{\Sigma}



\def\lan{\langle}
\def\ran{\rangle}
\def\p{\partial }
\def\eps{\varepsilon}
\def\th{\theta}
\def\i{\sqrt{-1}}
\def\phi{\varphi}
\def\lam{\lambda}
\def\ga{\gamma}
\def\L{\mathcal L}
\def\M{\mathcal M}
\def\N{\mathcal N}
\def\F{\mathcal F}
\def\C{\mathcal C}
\def\R{\Bbb R}
\def\Z{\Bbb Z}
\def\Om{\Omega}
\def\pom{\p  \Omega}
\def\bom{\overline\Omega}
\def\ol{\overline}
\def\noo{\noindent}
\def\I{\mathcal I}
\def\D{\nabla}
\def\bphi{\overline\phi}
\newcommand\nnb{\nonumber\\}
\newcommand\allv{v_{tt},t^mv_{ss},t^mv_{st},v_s,v_t}
\newcommand\allg{G_{tt},t^mG_{ss},t^mG_{st},G_s,G_t}
\newcommand\dc{\dot{C}^}
\newcommand\hra{\hookrightarrow}
\newcommand{\pnorm}[1]{\left\|#1\right\|_{L^p}}
\newcommand{\abs}[1]{\left|#1\right|}
\ExecuteOptions{dvips} \marginparwidth 0pt \oddsidemargin 0.5 truecm
\evensidemargin 0.5 truecm \marginparsep 0pt \topmargin -25pt
\textheight 22 truecm \textwidth 15.0 truecm
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\renewcommand\baselinestretch{1}
\newtheoremstyle{mythm}{1.5ex plus 1ex minus .2ex}{1.5ex plus 1ex
   minus .2ex}{\kai}{\parindent}{\song\bfseries}{}{1em}{}
\numberwithin{equation}{section}
\newtheorem{definition}{Definition}[section]
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{eg}{Example}
\newtheorem{proposition}{Proposition}[section]
\newtheorem{remark}{Remark} [section]
\newtheorem{corollary}{Corollary}[section]
\allowdisplaybreaks[4]


\begin{document}

In \cite{brezis1983positive}, Brezis and Nirenberg discussed 
\bibliographystyle{plain}
\bibliography{ref}

\end{document}  

My ref.bib code in the following:

@article{brezis1983positive,
  title={Positive solutions of nonlinear elliptic equations involving critical Sobolev exponents},
  author={Brezis, Ha{\"{i}}m and Nirenberg, Louis},
  journal={Communications on pure and applied mathematics},
  volume={36},
  number={4},
  pages={437--477},
  year={1983},
  publisher={Wiley Subscription Services, Inc., A Wiley Company New York}
}

When I build and see the latex, I have the following errors:

  • Missing $ inserted. Ha"{i}
  • Improper \spacefactor. Ha"{i}
  • Extra }, or forgotten $. Ha"{i}
  • Please use \mathaccent for accents in math mode. Ha"{i}
  • Missing { inserted. Ha"{i}
  • You can't use `\spacefactor' in math mode. Ha"{i}
  • Please use \mathaccent for accents in math mode. Ha"{i}m Br'{e}
  • You can't use `\spacefactor' in math mode. Ha"{i}m Br'{e}.

How can I correct this?

7
  • Welcome to TeX.SE. More information is likely required, could you extend your code into a small example that can compile please
    – JamesT
    Mar 18 at 11:48
  • 2
    Br \ '{e}is, Ha \ ''{i}m looks wrong. It should be Brezis, Ha{\"{i}}m. In particular the spaces are off and the diacritics for the "i" should be \"{i} with a " and not two ''. (Also the last name is Brezis according to doi.org/10.1002/cpa.3160360405 and not Bréis)
    – moewe
    Mar 18 at 11:57
  • See tex.stackexchange.com/q/57743/35864 for the details of writing accented characters in BibTeX files. (There are subtle differences to the "normal TeX way" of doing that.)
    – moewe
    Mar 18 at 12:00
  • It has the same error when I use Ha{\"{i}}m Mar 18 at 12:43
  • Unrelated but you are loading multiple of the same math classes, amsthm is loaded 4 times. Whilst it may not cause errors or issues in this question, loading the same class multiple times is not recommended. Hopefully someone can answer your .bib issue!
    – JamesT
    Mar 18 at 13:00

1 Answer 1

14

This is the minimal working example:

\documentclass{article}
\def\i{\sqrt{-1}}

\begin{document}

In \cite{brezis1983positive}
\bibliographystyle{plain}
\bibliography{ref}

\end{document}

When compiled with pdflatex (but not xelatex) it produces the said error. This is because \"i is translated to \"\i internally (I'm simplifying a bit), which triggers your redefinition of \i. And since square roots are defined in math mode, TeX is confused.

It is highly discouraged to use \def unless you know what you are doing. Use \newcommand or \renewcommand instead. Also, it is highly recommended that you do not redefine commands such as \i or \d. Because it will cause problems (such as now!).

As a final note, before asking technical questions --- not restricted to TeX or LaTeX related ones --- you should try your best to minimize your problem. Think of it as a challenge to use the smallest amount of code to produce the phenomenon you want to show. This process actually helps you, because it has a fair chance to already reveal the problem! On the other hand, this also helps others to diagnose the problem. In addition, you should provide some basic info, and if you are not qualified enough to judge whether a piece of information is relevant, you can provide it. For instance, the fact that xelatex copes just fine with your code will prevent others from investigating your problem.

1
  • 2
    Good advice. In general, it's not good practice to (re)define one-letter commands; many of them are already defined, and debugging surprises is never obvious and often complicated. I'd never seen the particular form \"{i} but I'll be using it as a "good bad example". Mar 18 at 18:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .