2

I am pretty new to Latex but I thought it would be better to write my bachelors thesis in latex than in word... its pretty easy to look up the main parts for latex but I'm at my wit's end:

A specific entry in my .bib file results in some problem in in-text citation. Following is my pre amble for the bibliography (I copied it from a friend's template. It should (and does nearly every time except this one) cite and build references in APA-Style

 \usepackage[babel=true]{csquotes}
\usepackage[style=apa,backend=biber,
%minbibnames=5, maxbibnames=5, %mincitenames=1, 
%maxcitenames=6, 
doi=false, url=false, sortcites=true, natbib]{biblatex}  
%\usepackage{apacite}
\bibliography{literatur.bib}
\DeclareLanguageMapping{ngerman}{ngerman-apa}
\DefineBibliographyStrings{ngerman}{andothers={et\ \addabbrvspace al\adddot}}
\AtBeginBibliography{%
  \renewcommand\finalandcomma{\addcomma}%
  \renewcommand*{\finalnamedelim}{%
    \ifthenelse{\value{listcount}>\maxprtauth}
      {}
      {\finalandcomma\addspace\&\space}}}
\newcommand*\mcite[1]{\citeauthor{#1} (\citeyear{#1})}
%\newcommand*\asdcite[1,2]{(\citeyear{#1};\citeauthor{#2},\citeyear{#2})}
%\newcommand*\xcite[1]{\citeauthor{#1} (\citeyear{#1}}
%\newcommand*\ycite[1]{\citeauthor{#1}, \citeyear{#1})}
\AtEveryBibitem{%
      \clearfield{day}%
      \clearfield{month}%
      \clearfield{endday}%
      \clearfield{endmonth}%
    }

  \renewcommand\maxprtauth{12}
\DeclareNameFormat{apaauthor}{%
  \ifthenelse{\value{listcount}=\maxprtauth \AND\value{listcount}<\value{listtotal}}
    {,~et~al.\addspace\setcounter{listcount}{\thelisttotal}}
    {\ifthenelse{\value{listcount}>\maxprtauth\AND\value{listcount}<\value{listtotal}}
      {}%
      {\ifthenelse{\iffieldequalstr{usere}{unkauth}\OR\iffieldequalstr{usere}{unkauthdate}}%
        {\iffirstinits
          {\mkbibbrackets{\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}?}}%
          {\mkbibbrackets{\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}?}}}%
        {\iffirstinits
          {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}%
          {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}}}}%
  \ifmorenames{\andothersdelim\bibstring{andothers}}{}}
\renewcommand\finalandcomma{\addcomma}

Now...I came across a weird error. I use the \citep and \citet options to cite my references in APA-Style either name and year in parentheses or only year in parentheses respectively. The error results when I want to cite a paper from Cohen, XY. First I thought there was something wrong with my bibliography but that wasn't the case.

The error looks like this: when I cite a reference the code generates a citation in APA style that does not contain any first names. But when I want to cite a paper written by an author called Cohen the \citep and \citet options result in compiling the first names into the citations.

As an Example

It was shown by \citep{cohen} that cows don't fly.

would result in

It was shown by M. M. Cohen & Massaro (1993) that cows don't fly.

and not in

It was shown by Cohen & Massaro (1993) that cows don't fly.

with the bibliography entry being:

@incollection{cohen,
title={Cows don't fly},
author={Cohen, Michael M and Massaro, Dominic W},
booktitle={Pigs fly},
pages={139--156},
year={1993},
publisher={Springer},
location={Tokyo}
}

This only happens if the first name after author={ is Cohen. I tried mixing the order of the names and stumbled upon that fact.

The best solution would be to mix the names up...but that is not the point of the references if this is the first named author.

I hope that someone will be able to help me =)

lockstep
  • 250,273
domix07
  • 21
  • 2
    do you have another entry with a Cohen? – Ulrike Fischer Aug 29 '15 at 22:09
  • 2
    I can only reproduce the issue by adding further entries involving a different Cohen. I can't reproduce just by putting your code fragments together and adding a minimal amount of code to make a compilable document. I don't understand the declaration of apaauthor, though. That seems weird: what is the point of saying if condition A holds, then do B; otherwise, do B? – cfr Aug 30 '15 at 00:42
  • I have other entries with a different Cohen as well. Cohen, Philip R. – domix07 Aug 30 '15 at 06:56
  • 1
    Ulrike Fischer and cfr have already put their finger on the major issue: It seems as though you have another Cohen (maybe even the same in a different name format) in your .bib file, biblatex then tries to disambiguate. I just want to point out a few other things. (1) Use andothers={et\addabbrvspace al\adddot} instead of \ \addabbrvspace, they will have the same output because biblatex is very clever, but at first it looks as though you want two spaces. (2) Your \mcite should do what \textcite/\citet already do. Why do you define a new command for that? ... – moewe Aug 30 '15 at 07:06
  • ... The way you use to define this command has sever drawbacks when citing multiple works and cannot handle pre- or postnotes. (3) The other commands \xcite and friends, look as if they should do manually what \cite{foo,bar} already does. But maybe I'm not getting the whole point of the two. Anyway, the do have the disadvantages mentioned above as well. (4) With your redefinition of apaauthor you lose APA compliance and the definitions looks kind of weird. It is never a good idea to hard code the et al. string .... – moewe Aug 30 '15 at 07:10
  • ... Do you know what the usere field does? In my recent version of biblatex-apa this check has been superseded by a much more transparent and understandable construction. Where did you get this from (or the base for your redefinition). – moewe Aug 30 '15 at 07:12
  • 4
    Since you have another Cohen this is just one of the nice features of biblatex to disambiguate the two authors (Philip and Michael). With the standard styles there are was to turn that off, that might also work with biblatex-apa, but since biblatex-apa has a very special name format it might not work. The features you are looking for are uniquename and uniquelist (see Literature with Biber generates strange citations: firstnames appear erratically for example). – moewe Aug 30 '15 at 07:15
  • 1
    I just did a check and biblatex-apa does support the uniquename and uniquelist features (at least in so far that I was able to get rid of first names in citations when using uniquename=false). Please check if uniquename=false (maybe plus unqiuelist=false) works for you and report back. – moewe Aug 30 '15 at 07:21
  • Hello there! Thanks for the explanations A LOT! I am still a newbie at Latex and try to learn as much as possible (need to make my own template after this thesis...) Here is a link to my project: https://www.sharelatex.com/project/55e2aa273877bc3347f04ee5

    @moewe yes! uniquename=false and uniquelist=false did the trick!

    – domix07 Aug 30 '15 at 07:33
  • @moewe because of me being a noob I couldn't fully understand all your points, sorry. could you tell me if the code for my bibliography is OK or how it should be changed to meet the APA 6th style? and thanks for solving my problem – domix07 Aug 30 '15 at 07:50
  • 1
    As far as I'm concerned biblatex-apa already implements the requirements of the APA by the book. So there should be no need at all to modify anything. If you feel that some of the output you get does not conform to the APA style, double check if everything is all right and if you are certain it shuld look different, contact the author of biblatex-apa and let him know (best via the github issue page). Instead of \mcite use \textcite (\citet if you prefer natbib names). – moewe Aug 30 '15 at 08:12
  • You seem to have some of the code from http://tex.stackexchange.com/q/62738/35864 and http://tex.stackexchange.com/q/166036/35864. You will note that the fisrt answer is from 2012 and since then quite some things in biblatex-apa have changed, so if you must have this output (it is not APA conform, mind) you better ask a new question with a pointer to this old one. The other answer of mine did not correct the slight mistakes I pointed out above, this has now been changed. – moewe Aug 30 '15 at 08:21
  • I'm quite intrigued now, these three questions were asked by totally different people, yet the MWEs seem so similar, is this some kind of template from your university? (While we are talking about templates, you might enjoy Minimale Vorlage vs. maximale Probleme) – moewe Aug 30 '15 at 08:22
  • @moewe it actually is a university template. it was changed to conform our own departments rules about formatting guidelines and so on. the second link (User Ferdinand) is actually this friend of mine whose code I used as a basis for mine. The first link's code looks like my code actually... somewhat tuned but the basis is the same – domix07 Aug 30 '15 at 08:44
  • 1
    I see, maybe someone should give them a hint then, that some snippets of code they use are somewhat unfortunate. (Just for my peace of minf change the line \DefineBibliographyStrings{ngerman}{andothers={et\ \addabbrvspace al\adddot}} to \DefineBibliographyStrings{ngerman}{andothers={et\addabbrvspace al\adddot}}, the output will be identical, but the code won't look horrible any more). I will vote to close your question as a duplicate of http://tex.stackexchange.com/q/91225/35864, but if you have any other questions feel free to as a new one. – moewe Aug 30 '15 at 08:48
  • 1
    BTW: You might want to have a look at some of the math stuff in your thesis. The brackets around vectors are far too large for my tastes, * is rarely used to signify multiplication in mathematics texts, sometimes letter fall out of the subscript: use p_{kl} instead of p_kl (check the difference!). If you want a dash (Gedankenstrich) you should use -- instead of just one hyphen, as in Markov chains -- although slightly mathematical -- are very interesting. – moewe Aug 30 '15 at 08:51
  • Thank you really much for your suggestions! I will look into it how to change the brackets! – domix07 Aug 30 '15 at 08:56
  • 1
    One last thing: With your definition of the transition matrix of a Markov chain only the sum over one row is necessarily one, the sum over a column might not be one (and is not in your example). Interestingly if both the row and column sum are one, the stationary vector will have a very nice form. Also such a stationary vector does not always exists, but certain conditions (aperiodicity and irreducibility) ensure the existence. (vP^n=V is really more an approximation for large n -- the last point is important, n needs to be large) – moewe Aug 30 '15 at 09:00
  • If you know someone that studies mathematics or physics you might just ask them to read your thesis and give you some hints about the maths typesetting involved. – moewe Aug 30 '15 at 09:03
  • You are giving me some really nice pointers for my thesis! It would be great if I could PM you or something but it seems that this options doesn't exist here. Thank you very much for your help with my code and my thesis! – domix07 Aug 30 '15 at 09:05
  • 1
    For a nice (but mathematical) introduction to Markov Chains you could read http://num.math.uni-goettingen.de/~f.werner/files/Stochastik_Skript.pdf, unfortunately the script is a bit dated now (the lecturer has a newer typographically nicer version that is only available via the school's intranet), but the content should still be fine. This was my first lecture on probability theory and Markov chains. – moewe Aug 30 '15 at 09:11

0 Answers0