Problems with fancyhdr and babel - latex

I wrote myself a thesis template a couple of years ago that I want to work with again. However, when I want to compile the document now, I get compilation errors. When I wrote the template I didn't get any errors.
I already traced the problem down to 2 packages: fancyhdr and babel. When I use both packages I get errors, when I use either package on its own there are no problems.
I removed all the unnecessary stuff from my template and could reproduce the problem with the MWE:
\documentclass[12pt,a4paper]{report}
\usepackage[left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%-----------------------------------------------------------------------
\usepackage[compatV3]{fancyhdr}
\pagestyle{plain}
% my custom header style
% \setlength{\headsep}{8pt}
% \setlength{\headheight}{40pt}
% \setlength{\skip\footins}{0cm}
% \renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{\thesection\ #1}}{}}
% \fancyhead[R]{\vspace{\baselineskip}\thepage}
% \fancyfoot[C]{}
\fancypagestyle{plain}{
% \fancyhead[L]{}
% \fancyhead[C]{}
% \fancyhead[R]{\vspace{\baselineskip}\thepage}
% \fancyfoot[C]{}
}
%-----------------------------------------------------------------------
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[autostyle=true,german=quotes]{csquotes}
\MakeOuterQuote{"}
%-----------------------------------------------------------------------
\usepackage{lipsum}
\begin{document}
\chapter{Ein Kapitel}
\section{Ein Abschnitt}
\lipsum{}
\section{Zweiter Abschnitt}
\lipsum{}
\chapter{Zweites Kapitel}
\section{Ein Abschnitt}
\lipsum{}
\section{Zweiter Abschnitt}
\lipsum{}
Das sind "Anführungszeichen".
\end{document}
I first suspected the problem to be with my custom header style but it seems that all it takes to generate the errors is to include the fancyhdr package.
For reference, this is the compilation log:
Win CP console initial and current in/out Win: (850, 65001), (1252, 1252)
Coding system for system and terminal: 'CP1252'
---
Rc files read:
NONE
Latexmk: This is Latexmk, John Collins, 17 Mar. 2022. Version 4.77, version: 4.77.
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': File changes, etc:
Changed files, or newly in use since previous run(s):
c:/Coding/other_projects/QuickTests/LaTeX/test.tex
Rule 'xelatex': The following rules & subrules became out-of-date:
xelatex
------------
Run number 1 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf --max-print-line=10000 -synctex=1 -interaction=nonstopmode -shell-escape -file-line-error -recorder -output-directory="out" "c:/Coding/other_projects/QuickTests/LaTeX/test.tex"'
------------
This is XeTeX, Version 3.141592653-2.6-0.999994 (MiKTeX 22.10) (preloaded format=xelatex.fmt)
\write18 enabled.
entering extended mode
(c:/Coding/other_projects/QuickTests/LaTeX/test.tex
LaTeX2e <2022-11-01>
L3 programming layer <2022-11-02> (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/base\report.cls
Document Class: report 2022/07/02 v1.4n Standard LaTeX document class
(C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/base\size12.clo)) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/geometry\geometry.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/graphics\keyval.sty) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifvtex.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty)) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/geometry\geometry.cfg)) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/fancyhdr\fancyhdr.sty) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/base\fontenc.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/lm\t1lmr.fd)) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/generic/babel\xebabel.def (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/generic/babel\txtbabel.def))
*************************************
* Local config file bblopts.cfg used
*
(C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/babel-german\ngerman.ldf (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/babel-german\ngermanb.ldf))) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/generic/babel/locale/de\babel-ngerman.tex) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/csquotes\csquotes.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/etoolbox\etoolbox.sty) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/csquotes\csquotes.def) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/csquotes\csquotes.cfg)) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/lipsum\lipsum.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/l3packages/l3keys2e\l3keys2e.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/l3kernel\expl3.sty (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-xetex.def))) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/lipsum\lipsum.ltd.tex)) (c:\Coding\other_projects\QuickTests\LaTeX\out\test.aux) (C:\Users\FMeinicke\AppData\Local\Programs\MiKTeX\tex/latex/base\ts1cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
Kapitel 1.
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:40: Argument of \__cmd_expandable_grab_D:NNNwNNn has an extra }.
<inserted text>
\par
l.40 \chapter{Ein Kapitel}
Runaway argument?
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:40: Paragraph ended before \__cmd_expandable_grab_D:NNNwNNn was complete.
<to be read again>
\par
l.40 \chapter{Ein Kapitel}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:40: Argument of \__cmd_expandable_grab_D:NNNwNNn has an extra }.
<inserted text>
\par
l.40 \chapter{Ein Kapitel}
Runaway argument?
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:40: Paragraph ended before \__cmd_expandable_grab_D:NNNwNNn was complete.
<to be read again>
\par
l.40 \chapter{Ein Kapitel}
Runaway argument?
{\protect \foreignlanguage {ngerman}{\protect \bbl#restore#actives \MakeUppercase \ETC.
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Paragraph ended before \#markright was complete.
<to be read again>
\par
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Extra }, or forgotten \endgroup.
\#themark ...store#actives \MakeUppercase {\par }
{Kapitel\ 1. \ Ein Kapitel...
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Extra }, or forgotten \endgroup.
\#themark ... {\par }{Kapitel\ 1. \ Ein Kapitel}}
}{}
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Extra }, or forgotten \endgroup.
\#themark ... {\par }{Kapitel\ 1. \ Ein Kapitel}}}
{}
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Argument of \__text_expand_loop:w has an extra }.
<inserted text>
\par
l.41 \section{Ein Abschnitt}
Runaway argument?
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Paragraph ended before \__text_expand_loop:w was complete.
<to be read again>
\par
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Missing number, treated as zero.
<to be read again>
\scan_stop:
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Argument of \#firstoftwo has an extra }.
<inserted text>
\par
l.41 \section{Ein Abschnitt}
Runaway argument?
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Paragraph ended before \#firstoftwo was complete.
<to be read again>
\par
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Use of \\bbl#foreign#x doesn't match its definition.
\kernel#ifnextchar ...d#d =#1\def \reserved#a {#2}
\def \reserved#b {#3}\futu...
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Argument of \\bbl#foreign#x has an extra }.
<inserted text>
\par
l.41 \section{Ein Abschnitt}
Runaway argument?
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Paragraph ended before \\bbl#foreign#x was complete.
<to be read again>
\par
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Undefined control sequence.
\bbl#fixname #1->\begingroup \def \bbl#tempe
{l#}\edef \bbl#tempd {\noexpand...
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Argument of \bbl#tempd has an extra }.
<inserted text>
\par
l.41 \section{Ein Abschnitt}
Runaway argument?
{\noexpand \#ifundefined {\noexpand \bbl#tempe \languagename }}\bbl#tempd \ETC.
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Paragraph ended before \bbl#tempd was complete.
<to be read again>
\par
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Undefined control sequence.
\bbl#fixname #1->\begingroup \def \bbl#tempe
{l#}\edef \bbl#tempd {\noexpand...
l.41 \section{Ein Abschnitt}
Runaway argument?
{\noexpand \#ifundefined {\noexpand \bbl#tempe \languagename }}\bbl#tempd \ETC.
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Paragraph ended before \bbl#tempd was complete.
<to be read again>
\par
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Missing \endcsname inserted.
<to be read again>
\#temptokena
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Missing \endcsname inserted.
<to be read again>
\#temptokena
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Missing \endcsname inserted.
<to be read again>
\#temptokena
l.41 \section{Ein Abschnitt}
c:/Coding/other_projects/QuickTests/LaTeX/test.tex:41: Missing number, treated as zero.
<to be read again>
\__text_change_case_letterlike_
l.41 \section{Ein Abschnitt}
)
Runaway text?
\__text_change_case_letterlike_ \#temptokena :nnN\cs_end: {\#temptokena \ETC.
! File ended while scanning text of \__kernel_exp_not:w.
<inserted text>
}
<*> ...ng/other_projects/QuickTests/LaTeX/test.tex
! Missing { inserted.
<to be read again>
:
<*> ...ng/other_projects/QuickTests/LaTeX/test.tex
! Emergency stop.
<*> ...ng/other_projects/QuickTests/LaTeX/test.tex
No pages of output.
Transcript written on c:\Coding\other_projects\QuickTests\LaTeX\out\test.log.
Latexmk: If appropriate, the -f option can be used to get latexmk
to try to force complete processing.
Reverting Windows console CPs to (in,out) = (850,65001)
Latexmk: Getting log file 'out/test.log'
Latexmk: Examining 'out/test.fls'
PWD line not in UTF-8
Latexmk: Examining 'out/test.log'
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
xelatex: Command for 'xelatex' gave return code 1
Refer to 'out/test.log' for details
I'm using MiKTeX 22.10 on Windows 10 and compiling with XeTeX (run by latexmk which is called with latexmk -synctex=1 -interaction=nonstopmode -shell-escape -file-line-error -pdfxe -outdir=out test.tex).
I read that the "Runaway argument" error has something to do with fragile commands but since the errors occur by simply including the fancyhdr package I don't really know what to do.

Related

How it is possible to convert LaTeX document to Word (docx file) with all cross-references and labels for images and equations, tables by Pandoc?

I have a tex-file obtained originally from RStudio with bookdown. The original set of Rmd-files were deleted by accident.
So I need to convert below minimized correct tex-file to Word (docx file extension):
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\#ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Simple document},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1in]{geometry}
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if#noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps#figure{htbp}
\makeatother
\usepackage[normalem]{ulem}
% Avoid problems with \sout in headers with hyperref
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage[]{biblatex}
\addbibresource{bibliography.bib}
\title{Simple document}
\author{}
\date{\vspace{-2.5em}}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{corollary}{Corollary}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{conjecture}{Conjecture}[section]
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\theoremstyle{definition}
\newtheorem{exercise}{Exercise}[section]
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\newtheorem*{solution}{Solution}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\hypertarget{format}{%
\section{Format}\label{format}}
Read \ref{format} for details.
Or read \protect\hyperlink{format}{format}.
Formatting:
\begin{itemize}
\tightlist
\item
sup-script or power - x\textsuperscript{2} ;
\item
sub-script - y\textsubscript{3} ;
\item
strike through - \sout{strike through} ;
\item
term -- definition ;
\item
long term --- long definition .
\end{itemize}
Here comes \textbf{footnote} \footnote{Footnote text} with its contents.
Image with caption, see \ref{fig:image}.
\begin{figure}
\centering
\includegraphics{image.png}
\caption{\label{fig:image} Image}
\end{figure}
Labeled table is below, see table \ref{tab:table}.
\begin{longtable}[]{#{}ll#{}}
\caption{\label{tab:table}\\
My table}\tabularnewline
\toprule
\textbf{Col 1 header} & \textbf{Col 2 header} \\
\midrule
\endfirsthead
\endhead
r1c1 & r1c2 \\
r2c1 & r2c2 \\
\bottomrule
\end{longtable}
Inline: \(a^2 + b^2 = c^2\).
Block:
\[ E = \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}} \]
Labeled, see \eqref{eq:eq}:
\begin{equation}
f\left(k\right) =\binom{n}{k} p^k\left(1-p\right)^{n k}
\label{eq:eq}
\end{equation}
See LaTeX \autocite{latex} site for details.
Code is below, see \ref{exm:code}:
\begin{example}
\protect\hypertarget{exm:code}{}{\label{exm:code} }Hello world
\end{example}
\begin{verbatim}
int main(){
return 0;
}
\end{verbatim}
\hypertarget{references}{%
\section*{References}\label{references}}
\addcontentsline{toc}{section}{References}
\printbibliography
\end{document}
When I try to convert it to docx using pandoc (2.16.1 version) command below:
pandoc simple.tex --to docx+native_numbering --output simple.docx --table-of-contents --toc-depth 5 --number-sections --citeproc --verbose --csl ieee.csl
(In the above command ieee.csl was downloaded from Zotero).
I get
and I see many strange things:
[fig:image] along with Figure with number;
[tab:table] along with Table with number;
[eq:eq] instead of equation number;
[exm:code] instead of example number.
Is it possible to replace (or suppress them for Figure and Table) above strange […] fields by correct numbers and links using Pandoc to get correct docx output?
This is currently not supported by plain pandoc, but you can use filters to get the numbering back. E.g., the resolve-references.lua filter in the OpenJournals "Inara" project does something comparable. You may have to adjust and extend it to fully suit your requirements.

*** (job aborted, no legal \end found) error in LaTex

I'm having an issue with LaTex.
I'm using Overleaf to ellaborate my thesis document, and when I try to compile it, I get this error:
<*> Preambulo.tex
*** (job aborted, no legal \end found)
I've seen other questions related to this issue, but none of them was helpful. The error seems to be in my Preambulo.tex file, which is a preamble that is supposed to include all the document settings. This is what my Preambulo.tex file looks like:
\documentclass[a4paper,11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,spanish,es-lcroman]{babel}
\usepackage{bookman}
\decimalpoint
\usepackage{graphicx}
\usepackage{amsfonts,amsgen,amsmath,amssymb}
\usepackage[top=3cm, bottom=3cm, right=2.54cm, left=2.54cm]{geometry}
\usepackage{afterpage}
\usepackage{colortbl,longtable}
\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage{pdfpages}
\usepackage{url}
\usepackage[stable]{footmisc}
\usepackage{parskip} % para separar párrafos con espacio.
\usepackage{hyperref}
%%-----------------------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}
\setlength{\headheight}{1.5\headheight}
\cfoot{\thepage}
\addto\captionsspanish{ \renewcommand{\contentsname}
{Tabla de contenidos} }
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\renewcommand{\chaptermark}[1]{\markboth{\textbf{#1}}{}}
\renewcommand{\sectionmark}[1]{\markright{\textbf{\thesection. #1}}}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\newcommand{\bigrule}{\titlerule[0.5mm]}
\usepackage{appendix}
\renewcommand{\appendixname}{Anexos}
\renewcommand{\appendixtocname}{Anexos}
%\renewcommand{\appendixpagename}{Anexos}
%%-----------------------------------------------
%% Páginas en blanco sin cabecera:
%%-----------------------------------------------
\usepackage{dcolumn}
\newcolumntype{.}{D{.}{\esperiod}{-1}}
\makeatletter
\addto\shorthandsspanish{\let\esperiod\es#period#code}
\def\clearpage{
\ifvmode
\ifnum \#dbltopnum =\m#ne
\ifdim \pagetotal <\topskip
\hbox{}
\fi
\fi
\fi
\newpage
\thispagestyle{empty}
\write\m#ne{}
\vbox{}
\penalty -\#Mi
}
\makeatother
%%-----------------------------------------------
%% Estilos código de lenguajes: Consola, C, C++ y Python
%%-----------------------------------------------
\usepackage{color}
\definecolor{gray97}{gray}{.97}
\definecolor{gray75}{gray}{.75}
\definecolor{gray45}{gray}{.45}
\usepackage{listings}
\lstset{ frame=Ltb,
framerule=0pt,
aboveskip=0.5cm,
framextopmargin=3pt,
framexbottommargin=3pt,
framexleftmargin=0.4cm,
framesep=0pt,
rulesep=.4pt,
backgroundcolor=\color{gray97},
rulesepcolor=\color{black},
%
stringstyle=\ttfamily,
showstringspaces = false,
basicstyle=\scriptsize\ttfamily,
commentstyle=\color{gray45},
keywordstyle=\bfseries,
%
numbers=left,
numbersep=6pt,
numberstyle=\tiny,
numberfirstline = false,
breaklines=true,
}
\lstnewenvironment{listing}[1][]
{\lstset{#1}\pagebreak[0]}{\pagebreak[0]}
\lstdefinestyle{consola}
{basicstyle=\scriptsize\bf\ttfamily,
backgroundcolor=\color{gray75},
}
\lstdefinestyle{CodigoC}
{basicstyle=\scriptsize,
frame=single,
language=C,
numbers=left
}
\lstdefinestyle{CodigoC++}
{basicstyle=\small,
frame=single,
backgroundcolor=\color{gray75},
language=C++,
numbers=left
}
\lstdefinestyle{Python}
{language=Python,
}
\makeatother
Does anyone know how to fix this issue? Thank you very much in advance.
For anyone interested on this problem, the issue seems to be that the main file selected in my overleaf project was wrong: it was Preamble.tex instead of main.tex
I went to the menu in the upper left corner of the page and changed the main file to main.tex. Now it works fine.
I received the same error because I was trying to compile my settings.tex file (which similarly lists all my document settings) instead of compiling my main.tex file. Make sure you are compiling the correct document.

Compile latex project on Linux through CLI

I'm trying to compile and automate the process of generating the PDF from this project [https://github.com/deedy/Deedy-Resume][1] on Linux machine(Ubuntu specifically). I'm finding it quite difficult to compile. I've tried different compilers but it always ends in errors and warnings.
Edit 1:
command run to create file:
xetex deedy_resume-openfont.xtx
log file output:
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**deedy_resume-openfont.xtx
(./deedy_resume-openfont.xtx
! Undefined control sequence.
l.48 \documentclass
[]{deedy-resume-openfont}
?
! Undefined control sequence.
l.49 \usepackage
{fancyhdr}
?
! Undefined control sequence.
l.51 \pagestyle
{fancy}
?
! Undefined control sequence.
l.52 \fancyhf
{}
?
! Undefined control sequence.
l.54 \begin
{document}
?
! Undefined control sequence.
l.61 \lastupdated
?
! Undefined control sequence.
l.68 \namesection
{Debarghya}{Das}{ \urlstyle{same}\href{http://debarghyadas....
?
! Undefined control sequence.
l.68 \namesection{Debarghya}{Das}{ \urlstyle
{same}\href{http://debarghyadas....
?
! Undefined control sequence.
l.68 ...tion{Debarghya}{Das}{ \urlstyle{same}\href
{http://debarghyadas.com}{...
?
! Undefined control sequence.
l.68 ...debarghyadas.com}{debarghyadas.com}| \href
{http://fb.co/dd}{fb.co/dd}\\
?
! Argument of \\ has an extra }.
<inserted text>
\par
<to be read again>
}
l.70 }
?
Runaway argument?
\href {mailto:deedy#fb.com}{deedy#fb.com} | 607.379.5733 | \href {ma\ETC.
! Paragraph ended before \\ was complete.
<to be read again>
\par
<to be read again>
}
l.70 }
?
! Undefined control sequence.
l.78 \begin
{minipage}[t]{0.33\textwidth}
?
! Undefined control sequence.
l.78 \begin{minipage}[t]{0.33\textwidth
}
?
! Undefined control sequence.
l.84 \section
{Education}
?
! Undefined control sequence.
l.86 \subsection
{Cornell University}
?
! Undefined control sequence.
l.87 \descript
{MEng in Computer Science}
?
! Undefined control sequence.
l.88 \location
{Dec 2014 | Ithaca, NY}
?
! Undefined control sequence.
l.89 \sectionsep
?
! Undefined control sequence.
l.91 \subsection
{Cornell University}
?
! Undefined control sequence.
l.92 \descript
{BS in Computer Science}
?
! Undefined control sequence.
l.93 \location
{May 2014 | Ithaca, NY}
?
Runaway argument?
Magna Cum Laude\\ \location { Cum. GPA: 3.83 / 4.0 \\ Major GPA: 3.9\ETC.
! Paragraph ended before \\ was complete.
<to be read again>
\par
l.99
?
! Undefined control sequence.
l.100 \subsection
{La Martiniere for Boys}
?
! Undefined control sequence.
l.101 \location
{Grad. May 2011| Kolkata, India}
?
! Undefined control sequence.
l.102 \sectionsep
?
! Undefined control sequence.
l.108 \section
{Links}
?
! Undefined control sequence.
l.109 Facebook:// \href
{https://facebook/dd}{\bf dd} \\
?
Runaway argument?
Github:// \href {https://github.com/deedydas}{\bf deedydas} \\ Linke\ETC.
! Paragraph ended before \\ was complete.
<to be read again>
\par
l.115
?
! Undefined control sequence.
l.120 \section
{Coursework}
?
! Undefined control sequence.
l.121 \subsection
{Graduate}
?
Runaway argument?
Open Source Software Engineering \\ Advanced Interactive Graphics \\\ETC.
! Paragraph ended before \\ was complete.
<to be read again>
\par
l.131
?
! Undefined control sequence.
l.132 \subsection
{Undergraduate}
?
Runaway argument?
Operating Systems \\ Artificial Intelligence + Practicum \\ Function\ETC.
! Paragraph ended before \\ was complete.
<to be read again>
\par
l.140
?
! Undefined control sequence.
l.145 \section
{Skills}
?
! Undefined control sequence.
l.146 \subsection
{Programming}
?
! Undefined control sequence.
l.147 \location
{Over 5000 lines:}
?
! Undefined control sequence.
l.148 Java \textbullet
{} Shell \textbullet{} Python \textbullet{} Javascri...
?
! Undefined control sequence.
l.148 Java \textbullet{} Shell \textbullet
{} Python \textbullet{} Javascri...
?
! Undefined control sequence.
l.148 ... Shell \textbullet{} Python \textbullet
{} Javascript \\
?
Runaway argument?
OCaml \textbullet {} Matlab \textbullet {} Rails \textbullet {} \LaTeX \ETC.
! Paragraph ended before \\ was complete.
<to be read again>
\par
l.155
?
[1] )
Output written on deedy_resume-openfont.pdf (1 page).```
[1]: https://github.com/deedy/Deedy-Resume

Latex using foreign language results in error in citations

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

Setting up author or address string variables in LaTeX

LaTeX is a wonderful language for writing documents. With the hyperref package and pdflatex, you easily generate documents with metadata, a nice feature to get your documents referenced right on the web.
I often use templates like:
\documentclass[11pt]{article}
\usepackage[pdftex, pdfusetitle,colorlinks=false,pdfborder={0 0 0}]{hyperref}%
\hypersetup{%
pdftitle={My title},%
pdfauthor={My name},%
pdfkeywords={my first keyword, my second keyword, more keywords.},%
}%
\begin{document}
\title{My title}
\author{My name}
\date{}
\maketitle
{\bf Keywords:} my first keyword, my second keyword, more keywords.%
My text is here...
\end{document}
So far, it's well. My question pops out from the example: is there a way to define string variables in the header so that they can be passed as arguments to hyperref and then to the frontmatter or to the text. Something like:
\documentclass[11pt]{article}
%-------definitions-----
\def\Author{My name}
\def\Title{My title}
\def\Keywords{my first keyword, my second keyword, more keywords.}
%--------------------------
\usepackage[pdftex, pdfusetitle,colorlinks=false,pdfborder={0 0 0}]{hyperref}%
\hypersetup{%
pdftitle={\Title},%
pdfauthor={\Author},%
pdfkeywords={\Keywords},%
}%
\begin{document}
\title{\Title}
\author{\Author}
\date{}
\maketitle
{\bf Keywords:} \Keywords %
My text is here...
\end{document}
This fails for the \maketitle part and for the hyperref metadata with ! Use of \Title doesn't match ! Argument of \let has an extra }.but also for including the keywords.
The correct template should look like:
\documentclass[11pt]{article}
%-------definitions-----
\newcommand{\Author}{My name}
\newcommand{\Title}{My title}
\newcommand{\Keywords}{my first keyword, my first keyword, more keywords.}
%--------------------------
\usepackage[pdftex, pdfusetitle,colorlinks=false,pdfborder={0 0 0}]{hyperref}%
\hypersetup{%
pdftitle={\Title},%
pdfauthor={\Author},%
pdfkeywords={\Keywords},%
}%
\begin{document}
\title{\Title}
\author{\Author}
\date{}
\maketitle
{\bf Keywords:} \Keywords %
My text is here...
\end{document}
Compiles fine and the metadata shows fine in the pdf reader.
Try using \newcommand{\Author}{My name} instead of \def.

Resources