1

It is hard for me to understand why some citations would work and the other wouldn't?

\documentclass[12pt]{article}
    \usepackage[margin=1in]{geometry} 
    \usepackage{amsmath,amsthm,amssymb}
     \usepackage{graphicx}
     \usepackage{verbatim}
     \usepackage{setspace}
    %\usepackage[square,sort,comma,numbers]{natbib}
    \usepackage{natbib}
    \usepackage{comment}
    \def\bibfont{\small}%
    \def\bibsep{\smallskipamount}%
    \def\bibhang{24pt}%
    \def\newblock{\ }%
    \def\BIBand{and}%


    \begin{document}

    I would like to cite \citep{Laroche2001} and \citep{Thogersen2002} and \citep{Young2010}

    \bibliographystyle{apalike} 

\bibliography{LiteratureSust} 

    \end{document}

These are the citations, where 1st and 3rd work but 2nd doesn't work):

@InCollection{Thogersen2002,
    author = {Thogersen, J.},
    title = {Promoting "green'' consumer behavior with eco- labels},
    booktitle = {New tools for environmental protection: Education, information, and voluntary measures},
    pages = {83-104},
    publisher = {Washington DC: National Academy Press},
    editor = {In T. Dietz \& P. Stern (Eds.)},
    year = {2002},
}
@ARTICLE{Laroche2001,
  AUTHOR =       "Laroche, M. and Bergeron, J. and Barbaro-Forleo, G.",
  TITLE =        "Targeting consumers who are willing to pay more for environmentally friendly products",
  JOURNAL =      "Journal of Consumer Marketing,",
  YEAR =         "2001",
  volume =       "18",
  number =       "6",
  pages =        "503-520",
}



@ARTICLE{Young2010,
  AUTHOR =       " Young, W. and Hwang, K and  McDonald, S. and  Oates, C. J.",
  TITLE =        "Sustainable consumption: Green consumer behaviour when purchasing products",
  JOURNAL =      "Sustainable Development,",
  YEAR =         "2010",
  volume =       "18",
  number =       "1",
  pages =        " 20-31",
}

After following one of the comments, this is what I have now:

enter image description here

enter image description here

    This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./Sustainability_Compreh_Paper.tex
LaTeX2e <2015/01/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2015/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amscls/amsthm.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/verbatim.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/setspace/setspace.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/natbib/natbib.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/comment/comment.sty
Excluding comment 'comment') (./Sustainability_Compreh_Paper.aux)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifluatex.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsb.fd)

LaTeX Warning: No \author given.


Package natbib Warning: Citation `EPA2016' on page 1 undefined on input line 54
.


Package natbib Warning: Citation `Boyle2009' on page 1 undefined on input line 
56.


Package natbib Warning: Citation `EPA2016' on page 1 undefined on input line 57
.


Package natbib Warning: Citation `Linton2007' on page 1 undefined on input line
 57.


Package natbib Warning: Citation `CocaCola2015' on page 1 undefined on input li
ne 57.


Package natbib Warning: Citation `Knickle2011' on page 1 undefined on input lin
e 57.


Package natbib Warning: Citation `Nestle2015' on page 1 undefined on input line
 57.


Package natbib Warning: Citation `Kraft2015' on page 1 undefined on input line 
57.


Package natbib Warning: Citation `Canada2009' on page 1 undefined on input line
 57.

[1{/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]

Package natbib Warning: Citation `UN2005' on page 2 undefined on input line 64.



Package natbib Warning: Citation `Gleim2013' on page 2 undefined on input line 
64.


Package natbib Warning: Citation `CR2007' on page 2 undefined on input line 64.



Package natbib Warning: Citation `luchs2010' on page 2 undefined on input line 
64.


Package natbib Warning: Citation `Balakrishnan2014' on page 2 undefined on inpu
t line 70.

[2]

Package natbib Warning: Citation `Johnsson1998' on page 3 undefined on input li
ne 74.

[3] [4] [5] <7.jpg, id=23, 2081.7775pt x 1513.655pt> <use 7.jpg> [6 <./7.jpg>]
[7] [8] [9] Excluding 'comment' comment. [10] [11]
<3.jpg, id=45, 2081.7775pt x 1513.655pt> <use 3.jpg>
Underfull \hbox (badness 10000) in paragraph at lines 242--243


Overfull \hbox (25.84772pt too wide) in paragraph at lines 291--294
\OT1/cmr/m/n/12 bil-ity func-tion, such that in-creas-ing $\OML/cmm/m/it/12 x$ 
\OT1/cmr/m/n/12 by 1 im-plies chang-ing fail-ure prob-a-bil-ity from $[][\OMS/c
msy/m/n/12 ^^@ []\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 ^^L[] \OT1/cmr/m/n/12 +
[12 <./3.jpg>] Excluding 'comment' comment. [13] Excluding 'comment' comment.
Excluding 'comment' comment. Excluding 'comment' comment.

Package natbib Warning: Citation `Young2010' on page 14 undefined on input line
 427.


Package natbib Warning: Citation `Laroche2001' on page 14 undefined on input li
ne 429.


Package natbib Warning: Citation `Bronnenberg2008' on page 14 undefined on inpu
t line 430.

(./Sustainability_Compreh_Paper.bbl)

Package natbib Warning: There were undefined citations.

[14] (./Sustainability_Compreh_Paper.aux) )
(\end occurred inside a group at level 1)

### semi simple group (level 1) entered at line 51 (\begingroup)
### bottom level
(see the transcript file for additional information)</usr/local/texlive/2015/te
xmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></usr/local/texlive/2015/tex
mf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/local/texlive/2015/texm
f-dist/fonts/type1/public/amsfonts/cm/cmbxti10.pfb></usr/local/texlive/2015/tex
mf-dist/fonts/type1/public/amsfonts/cm/cmcsc10.pfb></usr/local/texlive/2015/tex
mf-dist/fonts/type1/public/amsfonts/cm/cmmi12.pfb></usr/local/texlive/2015/texm
f-dist/fonts/type1/public/amsfonts/cm/cmmi8.pfb></usr/local/texlive/2015/texmf-
dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2015/texmf-di
st/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/local/texlive/2015/texmf-dist
/fonts/type1/public/amsfonts/cm/cmr6.pfb></usr/local/texlive/2015/texmf-dist/fo
nts/type1/public/amsfonts/cm/cmr8.pfb></usr/local/texlive/2015/texmf-dist/fonts
/type1/public/amsfonts/cm/cmsy10.pfb></usr/local/texlive/2015/texmf-dist/fonts/
type1/public/amsfonts/cm/cmsy8.pfb></usr/local/texlive/2015/texmf-dist/fonts/ty
pe1/public/amsfonts/cm/cmti12.pfb>
Output written on Sustainability_Compreh_Paper.pdf (14 pages, 685179 bytes).
SyncTeX written on Sustainability_Compreh_Paper.synctex.gz.
Transcript written on Sustainability_Compreh_Paper.log.

EDIT2: I do have these codes and still receive errors.

enter image description here

FINAL UPDATE:

I found the cause of my question marks in the document. In the LaTeX coding, I didn't include `\usepackage{url}'. I didn't know that for url citations you need that code (and in the original file, I had a plenty of them). Once I included it, everything worked.

Olga
  • 480
  • I have no problem generating the cross references right. Could you please what exactly the problem with second reference. Otherwise, please remove the .bbl file and do pdflatex filename; bibtex filename; pdflatex filename; pdflatex filename. – Jagath Jul 27 '16 at 03:06
  • It just says that that the author is undefined. – Olga Jul 27 '16 at 03:08
  • 1
    Your authors are incorrectly entered in the .bib file. – Alan Munn Jul 27 '16 at 03:13
  • What do you mean as "doesn't work"? – Tom Solid Jul 27 '16 at 03:47
  • I somehow have question marks for some of the references still, whereas others would work just fine. I am not sure what the root of my problem is. And I did what has been suggested so far. – Olga Jul 27 '16 at 10:42
  • If I compile your document with these .bib entries, (by running pdflatex, bibtex, pdflatex, pdflatex) I get an output. The output is complete although wrong due to the author field issue I note in the answer. When you run bibtex does it generate any errors or warnings? Have you looked at this question? Question mark or bold citation key instead of citation number – Alan Munn Jul 27 '16 at 15:53
  • @AlanMunn, I am not sure what is going on at all. I tried running the commands in that order, the interesting part, with every run of these commands, the output is changing too. At first, I would only have some question marks. Then, I would have all question marks. Then, I would lose apalike format and have numbers as references instead but all the question marks are gone. Currently, I am stuck with the third scenario. Please note that none of my input coding changed in all the three scenarios. – Olga Jul 27 '16 at 16:18
  • Delete all your .aux files and run the sequence again. Make sure the line in your code which passes the numbers option to natbib is deleted or at least commented out. You should not use this option with the apalike style. When you have done this, if the problem still persists, edit your question to include the top part of the .blg file (the part before the list of function calls). – Alan Munn Jul 27 '16 at 17:21
  • @AlanMunn, I updated the post. – Olga Jul 27 '16 at 19:50
  • This is the console output you get from the document you posted in your question? Or from a different document? The only way you can get the error you show is if you have no \citep commands, no \biliographystyle command and no \bibliography command in your document. With the posted document, this is simply impossible. – Alan Munn Jul 27 '16 at 19:53
  • @AlanMunn Please see a screen shot of a piece of my code in the updated version. Even with those codes, it provides question marks. – Olga Jul 27 '16 at 19:59
  • 1
    From the log file it is apparent that the document you're compiling is not the one you show. I say this after seeing \end occurred inside a group at level 1 – egreg Jul 27 '16 at 20:15
  • 1
    The current version (the simplified one that you show) compiles fine for me. Do you actually have a problem with that particular set of files? If yes, please edit the log file to correspond to the example file you show. If no, please go back to your original file and try to make a minimal example – Willie Wong Jul 27 '16 at 20:16
  • @egreg, you are correct. For the example, I removed almost all text and most citations simplifying the example. One of the commentators asked to show errors, so I included errors from my actual paper, which are essentially identical to the simplified version, it's just more of them. – Olga Jul 27 '16 at 20:20
  • Please see an update. I found a root cause. – Olga Jul 27 '16 at 23:05
  • What exactly do you mean by a "url citation"? – Alan Munn Jul 27 '16 at 23:57
  • @AlanMunnin In my bib file, I cite some sources with an url address: howpublished = \url{https://www.epa.gov/smm/advancing-sustainable-materials-management-facts-and-figures}". Without including \usepackage{url}, the bib file doesn't work at all. – Olga Jul 28 '16 at 01:26

1 Answers1

3

This answer addresses the original version of the question, and reflects problems with the posted code and bibliography entries.

The correct way to enter the Author field in a .bib file is:

Surname1, FirstName and Surname2, FirstName2 and Surname3, FirstName3

You need to separate each name with and and separate surnames from first names (or initials) with a comma. The order must always be Surname, FirstName for all names.

Although some other formats will work, (for example FirstName LastName will be treated correctly but will fail with two name surnames, for example) the method using Surname, FirstName is the best practice to get into the habit of doing.

There are other problems with the particular .bib entries you posted:

  • commas in some fields e.g. after journal names
  • formatting in the editor field; this field should contain only names, entered in the same way as regular author names
  • page numbers with hyphens (-) instead of en-dashes (--); this is not always necessary to do, but is also a good habit to get into

But none of these issues will result in the problem you are describing in your edited question because you are posting errors from a different document. The document you posted plus the exact .bib entries you posted will produce a compilable document. Although the formatting of the bibliography will be incorrect, the document will produce no errors.

Alan Munn
  • 218,180
  • This suggestion unfortunately doesn't fix the problem that I have. – Olga Jul 27 '16 at 10:42
  • @Olga Did you run bibtex? –  Jul 27 '16 at 19:53
  • 1
    @MarcvanDongen I did as suggested in the order pdflatex, bibtex, pdflatex, pdflatex. – Olga Jul 27 '16 at 20:03
  • @Olga: have you in fact fixed the author name ordering problem that Alan suggested? If so, please edit your original post to reflect that. As it reads currently the author lists in the second and third entries in your example is still not right. – Willie Wong Jul 27 '16 at 20:06
  • @WillieWong, here it is. – Olga Jul 27 '16 at 20:18
  • @WillieWong, I tried a simplified version of the piece as suggested and that tiny file worked for me. I am currently trying to see if the actual paper will work too. – Olga Jul 27 '16 at 20:30