2

I am writing a MSc. thesis and am writing it up in LaTex. I make use of natbib and am happy with how it generates a nice bibliography, but I am running into an issue where the format of the beginning of the bibliography changes after entry 15 to more of a blocky font.

Is this an issue with my usage of the natbib package?

% In Settings.tex
\usepackage{natbib}

% In References.tex
\setcitestyle{numbers}
\bibliographystyle{plainnat}
\bibliography{lit}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In main.tex, have already included settings.tex
% REFERENCES / BIBLIOGRAPHY 

\addcontentsline{toc}{chapter}{Bibliography} 
\begin{flushleft} 
\footnotesize 
\input{include/backmatter/References} 
\end{flushleft}

The respective .bib entries for 15 and 16:

@Misc{Giusca2005,
  author  = {Bogdan Giuşcă},
  title   = {The problem of the Seven Bridges of Königsberg.},
  year    = {2005},
  note    = {File: \ttfamily{Konigsberg bridges.png}},
  url     = {https://commons.wikimedia.org/wiki/File:Konigsberg_bridges.png},
  urlseen = {12-04-19},
}

@Article{Goldford2018,
  author    = {Goldford, Joshua E. and Lu, Nanxi and Baji{\'c}, Djordje and Estrela, Sylvie and Tikhonov, Mikhail and Sanchez-Gorostiaga, Alicia and Segr{\`e}, Daniel and Mehta, Pankaj and Sanchez, Alvaro},
  title     = {Emergent simplicity in microbial community assembly},
  journal   = {Science},
  year      = {2018},
  volume    = {361},
  number    = {6401},
  pages     = {469--474},
  issn      = {0036-8075},
  doi       = {10.1126/science.aat1168},
  eprint    = {http://science.sciencemag.org/content/361/6401/469.full.pdf},
  publisher = {American Association for the Advancement of Science},
  url       = {http://science.sciencemag.org/content/361/6401/469},
}

The bibliography style changes after entry 15, no matter how many additional sources I add

EDIT: Making some compilable .tex code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{natbib}

\title{msc}
\author{rosko }
\date{May 2019}

\begin{document}

\maketitle

\section{Introduction}
\citep{Giusca2005} did this
\citep{Goldford2018} did that

% \addcontentsline{toc}{chapter}{Bibliography} 
\newpage

\bibliographystyle{plainnat}
\bibliography{bib}

\end{document}

But with just these, the output has similar style: enter image description here

  • 2
    Welcome to TeX.se. The problem is probably in the .bib file entry for item 15. Can you edit your question and add that .bib item and make your code compilable. – Alan Munn May 1 at 19:50
  • My guess would be that whatever typesets the "File: Konigsberg bridges.png." has a leaking font definition (something like File: \ttfamily Konigsberg bridges.png. instead of File: {\ttfamily Konigsberg bridges.png}.). My money would be on the contents of the .bib file (maybe the note field?). But it could also be a bad BibTeX style. – moewe May 1 at 20:22
  • Aha! Indeed: note = {File: \ttfamily{Konigsberg bridges.png}}, is wrong. Write either note = {File: \texttt{Konigsberg bridges.png}}, (I would prefer this) or note = {File: {\ttfamily Konigsberg bridges.png}},. \ttfamily is a switch that changes the font until the end of the current group. It is not a macro that takes an argument. \texttt on the other hand is a macro with a normal argument. – moewe May 1 at 20:23
  • Problem resolved, \ttfamily was the issue. Will vote that as the solution if you add it, and will edit post to include the resolution. – WRosko May 1 at 20:26
  • No need to edit your post with a solution. @moewe can turn his comment into an answer and you can accept it by clicking the checkmark icon beside it once its posted. – Alan Munn May 1 at 20:31
2

For many font operations LaTeX knows two types of commands: Font switches and text macros. Font switches apply from the point they are written until the end of the current group. They do not take an argument. Text macros take an argument and generally only apply the formatting to that argument. Usually the name of the text macro includes begins with \text....

That implies that normally switches are used as

Unaffected text {\<switch> affected text} more unaffected text

and text macros as

Unaffected text \<text macro>{affected text} more unaffected text

For example \bfseries is a switch

normal text {\bfseries bold text} more normal text

and \textbf is the corresponding text macro

normal text \textbf{bold text} more normal text

You can read more about those commands at Braces inside or outside?, How to apply formatting (sans-serif, color etc.) to multiple paragraphs?, \bfseries is to \textbf as WHAT is to \textsf. In general there is no way you can know beforehand what the argument structure of a command is, i.e. if it is a switch or a text macro. You have to look it up or experiment. The only 'rule' is that many (if not all) text macros start with \text.... Many font switches end in \...series, \...font, \...shape, \...size.


\ttfamily is a font switch. Its effect persist until the current group is closed. When the note field contains

note    = {File: \ttfamily{Konigsberg bridges.png}},

then the effect of \ttfamily doesn't end at the } after .png. Instead it persists until the current group is ended. In the example that is only at the very end of the bibliography.

Instead of \ttfamily you want to use \texttt. That command takes and argument and typesets it in typewriter font.

note    = {File: \texttt{Konigsberg bridges.png}},

Alternatively, you could restrict \ttfamily with proper grouping

note    = {File: {\ttfamily Konigsberg bridges.png}},
  • +1 How to turn a simple problem into a really useful answer! – Alan Munn May 1 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.