Latex using foreign language results in error in citations - latex

When including LaTeX foreign language packages:
\usepackage[utf8x]{inputenc}
\usepackage[english,hebrew]{babel}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}
I get an error for the citations:
Example:
Missing number, treated as zero.
<to be read again>
\afterassignment
l.19 ...{example1}}}{\##number {27}}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
Another Example:
Improper alphabetic constant.
<to be read again>
\afterassignment
l.86 ...15normalized}. \citet{example2}
further improved the resu...
A one-character control sequence belongs after a ` mark.
So I'm essentially inserting \0 here.
! Missing = inserted for \ifnum.
<to be read again>
\afterassignment
l.86 ...15normalized}. \citet{example2}
further improved the resu...
I was expecting to see `<', `=', or `>'. Didn't.
And the citations are empty.
When I don't include the foreign language packages I don't get the error and the citations are great.
The format I used for citations is \usepackage{natbib} and for the document \documentclass[12pt,twoside]{mitthesis}.
I also tried other formats and get the same error.
bibliography.bib is traditional:
#article{example1,
title={Title1},
author={Author},
journal={arXiv preprint arXiv:1706.04902},
year={2019}
}
#article{example2,
title={Title2},
author={Author},
journal={arXiv preprint arXiv:1706.04902},
year={2019}
}
Minimal Working Example is super basic, (the minimal Not-Working Example is when you uncomment the Hebrew part):
\documentclass{report}
%\documentclass[12pt,twoside]{mitthesis}
\usepackage{natbib}
% Hebrew
% \usepackage[utf8x]{inputenc}
% \usepackage[english,hebrew]{babel}
% \usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}
\begin{document}
%\selectlanguage{english}
\include{introduction} %some text with \cite{example1} and so on...
% bibliography
\bibliography{bibliography}
\bibliographystyle{plainnat}
\end{document}

To avoid the problems load natbib after babel:
\documentclass{report}
%\documentclass[12pt,twoside]{mitthesis}
% Hebrew
\usepackage[utf8]{inputenc}
\usepackage[english,hebrew]{babel}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}
\usepackage{natbib}
\begin{filecontents}{bibliography.bib}
#article{example1,
title={Title1},
author={Author},
journal={arXiv preprint arXiv:1706.04902},
year={2019}
}
#article{example2,
title={Title2},
author={Author},
journal={arXiv preprint arXiv:1706.04902},
year={2019}
}
\end{filecontents}
\begin{document}
% \selectlanguage{english}
\cite{example1,example2}
{
\selectlanguage{english}
\cite{example1,example2}
}
% bibliography
% \selectlanguage{english}
\bibliography{bibliography}
\bibliographystyle{plainnat}
\selectlanguage{english}
\bibliography{bibliography}
\bibliographystyle{plainnat}
\end{document}
https://www.overleaf.com/read/kgrzpznmzjcz

Related

LaTeX: Citation found in .bib-file but only name of citation returned, bibliography not printed

I got this issue in LayteX (Overleaf) where the \cite{} and \textcite{} command does find my source, but then returns the exact name of the source in my .bib-file. It looks something like this (I couldn't add images somehow):
text...(world'bank"2022)....text.
While the correct output should be:
text... (World Bank, 2022) .... text
The source:
#online{world_bank_2022,
title = {World Bank Open Data {\textbar} Data},
url = {https://data-worldbank-org.eur.idm.oclc.org/},
author = {{World Bank}},
urldate = {2022-10-07},
date = {2022},
file = {World Bank Open Data | Data:C\:\\Users\\jhans\\Zotero\\storage\\X739YI3J\\data-worldbank-org.eur.idm.oclc.org.html:text/html},
}
The package and file name. Name of the bib-file corresponds 1:1 with the imported library file:
\usepackage[backend=biber, style=apa]{biblatex}
\addbibresource{Bibliography-ASP.bib}
And as a result, the following command also does not return anything:
\newpage
\printbibliography
The error messages are:
Empty bibliography on input line 360.
Overfull \hbox (6.3094pt too wide) in paragraph at lines 34--35
Citation 'world_bank_2022' on page 1 undefined on input line 34.
As an illustration, I created a MWE with the exact same structure and packages as in my original file.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{multirow,booktabs,setspace,caption}
\usepackage{tikz}
\usepackage{ntheorem}
\usepackage{longtable}
\newtheorem{hyp}{H}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{minted}
\usepackage{wrapfig}
\usepackage{csquotes}
\usepackage{hyperref}
\usepackage[backend=biber, style=apa]{biblatex}
\addbibresource{Bibliography IIA ASP.bib}
\title{AS\&P Assignment 3}
\author{Hans van Beek, 497005}
\date{14 October 2022}
\begin{document}
\maketitle
\section{Panel Data Modelling: Time-to-Export}\label{q1}
\subsection{Hypotheses}\label{q1: hypotheses}
The current analysis focuses on three hypothesised determinants of the time-to-export in hours (\textit{time\_to\_export}) between countries and over time using data from the World Bank (\cite{world_bank_2022}). The time-to-export is an important indicator of a country's quality of export and import conditions with a lower time-to-export (\textit{time\_to\_export}) in hours reflecting a more efficient economy. An appropriate determinant of the variation in the size of a country's economy could therefore be the GDP per capita (providing a good benchmark). The first hypothesis (i) therefore states that a higher GDP is
\newpage
\printbibliography
\newpage
\end{document}

Applying operations from the `calculator` package to conditional numerical values

I'm writing a LaTeX template that works similar to a spreadsheet: One defines a small number of variables and the whole document is adjusted accordingly.
I have three variables: Level, ProficiencyBonus and AbilityScore. Here is my MWE:
\documentclass{article}
\usepackage{ifthen}
\usepackage{calculator}
\begin{document}
\newcommand\Level{3}
\newcommand\ProficiencyBonus{%
\ifthenelse{\Level<5}{2}{3}%
}
\newcommand\AbilityScore{%
\ADD{\ProficiencyBonus}{10}{\TMP}%
\TMP%
}
Level: \Level \\
Proficiency Bonus: \ProficiencyBonus \\
Ability Score: \AbilityScore
\end{document}
This snippet produces and error during the addition:
Missing number, treated as zero.
Illegal unit of measure (pt inserted).
I suspect that \ifthenelse somehow doesn't return the "pure" number (are there "invisible" additional tokens?). However, I don't know how to debug this problem: I tried unsuccessfully to gain insight in the return value of \ifthenelse using \show and \meaning.
I'd appreciate any help that either solves this problem or shows me how to debug such a situation.
(I use XeLaTeX but this error appears also with normal LaTeX.)
You can use \ifnum for your test:
\documentclass{article}
\usepackage{ifthen}
\usepackage{calculator}
\begin{document}
\newcommand\Level{3}
\newcommand\ProficiencyBonus{%
\ifnum\Level<5
2
\else
3
\fi
}
\newcommand\AbilityScore{%
\ADD{\ProficiencyBonus}{10}{\TMP}%
\TMP%
}
Level: \Level \\
Proficiency Bonus: \ProficiencyBonus \\
Ability Score: \AbilityScore
\end{document}

affiliations and corresponding author comment as footnotes on latex article

I am trying to use the LaTeX article document class to create a simple paper with the authors listed on the title page with their (potentially multiple repeating) affiliations as numeric footnotes and other author comments as symbolic footnotes. For example, I want something like
However, I haven't been able to make this happen despite trying multiple different solutions. Is there a simple way to do this?
I have tried using the bigfoot package to create multiple different types of footnotes combined with footmisc with the multiple option to get multiple footnote markers with commas between them, but I end up with superposed markers and no footnotes. My minimal latex document is:
\documentclass{article}
\title{My title}
\usepackage[multiple]{footmisc}
\usepackage{bigfoot}
\DeclareNewFootnote{AAffil}[arabic]
\DeclareNewFootnote{ANote}[fnsymbol]
\author{
David Kaplan\footnoteAAffil{A University}\footnoteAAffil{Another University}\footnoteANote{Corresponding author}\footnoteANote{Equal contributors}
\and
Prince Charming\FootnotemarkAAffil{2}\FootnotemarkANote{2}
}
\date{\today}
\begin{document}
\maketitle
\end{document}
And the output I get is:
One possibility is to switch to the amsart class and then using the amsaddr package:
\documentclass{amsart}
\title{My title}
\author{David Kaplan $^{1,2,\ast,\dagger}$}
\address{$^1$A University}
\address{$^2$Another University}
\address{$^{\ast}$Corresponding author}
\address{$^{\dagger}$Equal contributors}
\author{Prince Charming $^{1,\dagger}$}
\usepackage[foot]{amsaddr}
\begin{document}
\maketitle
\end{document}
With help from others, I posted a solution to this question here. For completeness, I am copying the solution below:
\documentclass{article} % <---- No titlepage
\title{My title}
%\usepackage[dont-mess-around]{fnpct} % <---- I decided not to use fnpct, but rather put in the commas by hand
\usepackage{bigfoot}
\DeclareNewFootnote{AAffil}[arabic]
\DeclareNewFootnote{ANote}[fnsymbol]
\usepackage{etoolbox}
\makeatletter
\patchcmd\maketitle{\def\#makefnmark{\rlap{\#textsuperscript{\normalfont\#thefnmark}}}}{}{}{}
\makeatother
% Hook into the \thanks command for the article class to print the footnotes
\makeatletter
\def\thanksAAffil#1{% <--- These %'s are necessary for spacing
\footnotemarkAAffil\protected#xdef\#thanks{\#thanks%
\protect\footnotetextAAffil[\the \c#footnoteAAffil]{#1}}%
}
\def\thanksANote#1{%
\footnotemarkANote%
\protected#xdef\#thanks{\#thanks%
\protect\footnotetextANote[\the \c#footnoteANote]{#1}}%
}
\makeatother
\author{% <---- Not sure if these %'s are necessary, but can't hurt
David Kaplan%
\thanksAAffil{A University}$^{,}$\thanksAAffil{Another University}$^{,}$%
\thanksANote{Corresponding author}$^{,}$\thanksANote{Equal contributors}%
, %
Prince Charming%
\footnotemarkAAffil[2]$^{,}$\thanksAAffil{Still another university}$^{,}$\footnotemarkANote[2]$^{,}$%
\thanksANote{Another note}%
, %
Mohamed Ali%
\thanksAAffil{I am the greatest U.}%
}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
This is the abstract.
\end{abstract}
\section{Introduction}
More Text
\end{document}

I cant get the references correct for my document. Caption and label are in the correct order [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
So i cant get the references correct in my latex document. I've read about caption and label being in the correct order and i already have that. below are is a working document.tex with the error.
I'm still using a local file, because i dont know how to fix that. But it is just a random png image on my machine and that is working
\documentclass[a4paper, twocolumn]{report}
\usepackage[dutch]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage{ebgaramond}
% Bibliography
\usepackage[style=apa]{biblatex}
\usepackage{csquotes}
\addbibresource{bibliography.bib}
% Translation for references to objects
\makeatletter
\def\HyLang#dutch{%
\def\equationautorefname{Vergelijking}%
\def\footnoteautorefname{voetnoot}%
\def\itemautorefname{item}%
\def\figureautorefname{Figuur}%
\def\tableautorefname{Tabel}%
\def\partautorefname{Deel}%
\def\appendixautorefname{Bijlage}%
\def\chapterautorefname{hoofdstuk}%
\def\sectionautorefname{sectie}%
\def\subsectionautorefname{subsectie}%
\def\subsubsectionautorefname{subsubsectie}%
\def\paragraphautorefname{paragraaf}%
\def\subparagraphautorefname{subparagraaf}%
\def\FancyVerbLineautorefname{lijn}%
\def\theoremautorefname{Stelling}%
\def\pageautorefname{pagina}%
}
\g#addto#macro\extrasdutch\HyLang#dutch
\makeatother
\addto\captionsdutch{%
\renewcommand{\appendixname}%
{Bijlage}%
}
\usepackage[hidelinks]{hyperref}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{wallpaper}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\pgfplotsset{compat=1.15}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
% Table format
\pgfplotstableset{
every head row/.style={
before row=\toprule,after row=\midrule},
every last row/.style={
after row=\bottomrule},
col sep = comma,
string type,
}
% Colors
\definecolor{title-color}{HTML}{4230b8}
% Title formats with custom coloring
\titleformat{\chapter}
{\normalfont\bfseries\Huge\color{title-color}}{\thechapter.}{10pt}{}
\titleformat*{\section}{\normalfont\Large\bfseries\color{title-color}}
\titleformat*{\subsection}{\normalfont\large\bfseries\color{title-color}}
\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries\color{title-color}}
% No page number on TOC page
\addtocontents{toc}{\protect\thispagestyle{empty}}
\begin{document}
\chapter{Planning}
\label{chap:schedule}
First ref to figure \autoref{fig:schedule}
\begin{figure}[h]
\centering
\caption{Planning}
\includegraphics[width=\textwidth]{img/schedule.png}
\label{fig:schedule}
\end{figure}
\end{document}
Output:
First ref to figure Figuur 1.1
Figuur 1.1: Planning
It should be figure 1 instead of figure 1.1
You can use the chngcntr package to use \counterwithout{figure}{chapter}
\documentclass[a4paper, twocolumn]{report}
\usepackage[dutch]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage{ebgaramond}
% Bibliography
\usepackage[style=apa]{biblatex}
\usepackage{csquotes}
\addbibresource{bibliography.bib}
% Translation for references to objects
\makeatletter
\def\HyLang#dutch{%
\def\equationautorefname{Vergelijking}%
\def\footnoteautorefname{voetnoot}%
\def\itemautorefname{item}%
\def\figureautorefname{Figuur}%
\def\tableautorefname{Tabel}%
\def\partautorefname{Deel}%
\def\appendixautorefname{Bijlage}%
\def\chapterautorefname{hoofdstuk}%
\def\sectionautorefname{sectie}%
\def\subsectionautorefname{subsectie}%
\def\subsubsectionautorefname{subsubsectie}%
\def\paragraphautorefname{paragraaf}%
\def\subparagraphautorefname{subparagraaf}%
\def\FancyVerbLineautorefname{lijn}%
\def\theoremautorefname{Stelling}%
\def\pageautorefname{pagina}%
}
\g#addto#macro\extrasdutch\HyLang#dutch
\makeatother
\addto\captionsdutch{%
\renewcommand{\appendixname}%
{Bijlage}%
}
\usepackage[hidelinks]{hyperref}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{wallpaper}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\pgfplotsset{compat=1.15}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
% Table format
\pgfplotstableset{
every head row/.style={
before row=\toprule,after row=\midrule},
every last row/.style={
after row=\bottomrule},
col sep = comma,
string type,
}
% Colors
\definecolor{title-color}{HTML}{4230b8}
% Title formats with custom coloring
\titleformat{\chapter}
{\normalfont\bfseries\Huge\color{title-color}}{\thechapter.}{10pt}{}
\titleformat*{\section}{\normalfont\Large\bfseries\color{title-color}}
\titleformat*{\subsection}{\normalfont\large\bfseries\color{title-color}}
\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries\color{title-color}}
% No page number on TOC page
\addtocontents{toc}{\protect\thispagestyle{empty}}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\begin{document}
\chapter{Planning}
\label{chap:schedule}
First ref to figure \autoref{fig:schedule}
\begin{figure}[h]
\centering
\caption{Planning}
\includegraphics[width=\textwidth]{example-image}
\label{fig:schedule}
\end{figure}
\end{document}

Changing citation language in latex

I am trying to include citations APA style in my latex document which is written in dutch. However, the citations appear as
author e.a. (year)
instead of
author et al. (year)
The first is probably some translation, but in dutch is is very common to still use et al. How do I change the citations in text to et al.?
\documentclass[dutch]{article}
\usepackage[utf8]{inputenc}
\usepackage[dutch]{babel}
\usepackage{csquotes}
\usepackage[style=apa, backend=bibtex]{biblatex}
\addbibresource{Refrences.bib}
\begin{document}
\begin{otherlanguage}{dutch}
Dit is een test. \cite{Schleigh2015}. \cite{Slater2015}
\bibliography{bibliography}
\printbibliography
\end{otherlanguage}
\end{document}
output:
Dit is een test. Schleigh e.a., 2015. Slater e.a., 2015
Also, i just discoverd that apperently this apa style does not print an "&" when more than three authors are present. Instead in prints the word "and", which is not apa.
Author1, Author2 AND Author3
which should be:
Author1, Author2 & Author3
Luckily you use the biblatex package, this makes it easy to adjust the string:
\documentclass[dutch]{article}
\usepackage[utf8]{inputenc}
\usepackage[dutch]{babel}
\usepackage{csquotes}
\usepackage[style=apa, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}
\DefineBibliographyStrings{dutch}{
andothers = {et\addabbrvspace al\adddot},
andmore = {et\addabbrvspace al\adddot},
}
\begin{document}
Dit is een test. \cite{aksin}.
\printbibliography
\end{document}
Some other comments about your code:
apa styles requires the biber backend. With your attempt to use it with biblatex, you should have gotten an error messages telling you that. Please do not ignore error messages
your are mixing syntaxes from two different bibliography tools. \addbibresource{...} and \printbibliography are correct syntax for biblatex. \bibliography{bibliography} is not.
with \usepackage[dutch]{babel} you already changed the main language of your document to dutch, \begin{otherlanguage}{dutch}...\end{otherlanguage} is not necessary

Resources