4

When I use this code:

\documentclass[portuges]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[square,numbers]{natbib}
\usepackage{indentfirst}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xcolor}
\usepackage{geometry}
\geometry{tmargin=2cm,lmargin=2.2cm,rmargin=2cm,bmargin=2.2cm}

\begin{document}

\bibliographystyle{plainnat}
\bibliography{Ref}

\end{document}

I keep getting:

Package natbib Warning: Citation `Frid' on page 5 undefined on input line 167.

Package natbib Warning: Citation `artcl' on page 5 undefined on input line 173.

Package natbib Warning: Citation `cap' on page 5 undefined on input line 190.

(TPC_eletro.bbl
! Illegal parameter number in definition of \reserved@a.
<to be read again>

What am I doing wrong? My bib file looks like this:

@Book{Frid,
  author    = {Fridman, Alexander},
  publisher = {Taylor \& Francis},
  title     = {Plasma physics and engineering},
  year      = {2004},
  address   = {New York},
  isbn      = {1560328487},
  pages     = {559-560},
  pagetotal = {2},
}

@Article{artcl,
  author  = {Alice Hong},
  title   = {Dielectric Strength of Air},
  year    = {2000},
  comment = {An educational, fair use website},
  url     = {https://hypertextbook.com/facts/2000/AliceHong.shtml},
}

@Article{cap,
  title = {Cylindrical Capacitor},
  year  = {2006},
  url   = {http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capcyl.html#c2},
}

@Article{plast,
  journal = {Omnexus},
  title   = {Dielectric Constant},
  year    = {2015},
  comment = {An educational, fair use website},
  url     = {https://omnexus.specialchem.com/polymer-properties/properties/dielectric-constant},
}

And it was working perfectly fine without the natbib package.

5
  • 1
    Delete the temporary .aux and .bbl files. Then recompile with LaTeX, BibTeX, LaTeX, LaTeX (where "LaTeX" can be your favourite flavour of LaTeX: pdfLaTeX, LuaLaTeX, XeLaTeX, ...)
    – moewe
    May 31, 2020 at 15:03
  • 1
    The entries artcl, cap and plast are strictly speaking not @articles. @misc would be more appropriate (with plainnat, other styles may define more specific types for online resources such as @online or @electronic). The pagetotal = {2}, in Frid looks wrong and it is unusual to give a page field for @book entries (see for example my comment at the end of the answer to tex.stackexchange.com/a/547181/35864).
    – moewe
    May 31, 2020 at 15:06
  • I have tried deleting the files. Nothing changes... I changed the entries type, thanks May 31, 2020 at 15:10
  • 2
    Ah, I see now. You need to load the url package (\usepackage{url}) so the URL http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capcyl.html#c2 from caps works. (If you want links in your document you can load hyperref [\usepackage{hyperref}] instead of url, because hyperref loads url automatically.)
    – moewe
    May 31, 2020 at 15:12
  • Thank you so much!! May 31, 2020 at 15:14

1 Answer 1

4

Whenever you are typesetting URLs in your document it is a good idea to load the url or hyperref package (load url if you only care about URLs, load hyperref if you want linked URLs and additional links in your document for example from \ref or in the table of contents; hyperref loads url so there is generally no need to load both).

If neither url nor hyperref is loaded, natbib uses a fallback definition to print URLs that can not deal with special characters like # properly. In case such a character appears in a URL you may get very cryptic error messages like the only quoted in the question.

\documentclass[portuges]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[square,numbers]{natbib}
\usepackage{url}
% or
%\usepackage{hyperref}

\begin{filecontents}{\jobname.bib}
@misc{cap,
  title = {Cylindrical Capacitor},
  year  = {2006},
  url   = {http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capcyl.html#c2},
}
\end{filecontents}

\begin{document}
\citep{cap}

\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}

Nicely typeset bibliography entry with URL

You must log in to answer this question.

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