2

I have a tikzpicture in my latex document. Additionally, I have a text from the lipsum library. The document compiles normally and the tikzpicture looks normal. For some reason, when I remove the lipsum text, a fatal error is generated and the document no longer compiles. Additionally, the error is pointed out in a line of code in the tikzpicture. I know, it's a very strange error.

I don't understand why having or not having a lipsum text would affect whether an error appears in the tikzpicture. Tikz and lipsum seem to be packages that have nothing to do with each other.

Attached I leave the latex code. If you compile it, try removing the line \lipsum[1] and you will see that a fatal error occurs.

I am using ovealeaf to compile the code. Maybe it's an overleaf error? I already tried to compile the same code in another document from another overleaf account and the error still persists.

I would greatly appreciate your help.

\documentclass[11pt,a4paper]{article}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz} 
\usepackage{fancyhdr} 
\usepackage{hyperref} 
\usepackage{apacite} 
\usepackage{bibentry} 
\usepackage{lipsum} 
\usepackage[rmargin=2.54cm,lmargin=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}

\pagestyle{fancy}
\fancyhf{} 
\rhead{Author}
\lhead{Title}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[CE,CO]{Institution}


\title{Title}
\author{author}
\date{\today}

\begin{document}

\maketitle
\thispagestyle{fancy}

\section{Some text}

\noindent Some text....

\section{Some text}

\noindent Some text....

\lipsum[1]    %   Try changing this!!!!

\begin{center}
\begin{tikzpicture}
    %%%
    \foreach \x [count=\i from 0] in {-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7} {
        \node at (\i, 2) {\x};
    }

    %%%
    \foreach \i in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {
        \node[anchor=west] at (\i, 1) {(+8)}; % Ajuste a la derecha usando anchor=west
    }

    %%%
    \foreach \x [count=\i from 0] in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {
        \node at (\i, 0) {\x};
    }

    %%%
    \foreach \i in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {
        \draw[->] (\i, 1.7) -- (\i, 0.3);
    }
\end{tikzpicture}
\end{center}

\bibliographystyle{apacite}
\bibliography{citas}

\end{document}
2
  • Welcome! We don't have citas.bib, so we cannot compile this to reproduce the error. Can you fix this? Please also paste the text of the first error into your question.
    – cfr
    Commented Jun 18 at 0:57
  • This must be a duplicate, but finding them takes longer than answering.
    – cfr
    Commented Jun 18 at 1:03

1 Answer 1

2

Use the babel library. The error is due to the use of Babel's shorthands for Spanish.

I've commented out inputenc, which you don't need, and lipsum, which you won't want. I also had to comment out your bibliography, but that is unrelated - I just don't have your .bib file.

\documentclass[11pt,a4paper]{article}
\usepackage[spanish]{babel}
% \usepackage[utf8]{inputenc}% do not use with non-ancient latex
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz} 
\usepackage{fancyhdr}  
\usepackage{apacite} 
\usepackage{bibentry} 
% \usepackage{lipsum} 
\usepackage[rmargin=2.54cm,lmargin=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}
\usepackage{hyperref}% load late

\pagestyle{fancy}
\fancyhf{} 
\rhead{Author}
\lhead{Title}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[CE,CO]{Institution}


\title{Title}
\author{author}
\date{\today}

\usetikzlibrary{babel}

\begin{document}
  
  \maketitle
  \thispagestyle{fancy}
  
  \section{Some text}
  
  \noindent Some text....
  
  \section{Some text}
  
  \noindent Some text....
  
%   \lipsum[1]    %   Try changing this!!!!
  
  \begin{center}
    \begin{tikzpicture}
      %%%
      \foreach \x [count=\i from 0] in {-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7} {
        \node at (\i, 2) {\x};
      }
      
      %%%
      \foreach \i in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {
        \node[anchor=west] at (\i, 1) {(+8)}; % Ajuste a la derecha usando anchor=west
      }
      
      %%%
      \foreach \x [count=\i from 0] in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {
        \node at (\i, 0) {\x};
      }
      
      %%%
      \foreach \i in {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} {
        \draw[->] (\i, 1.7) -- (\i, 0.3);
      }
    \end{tikzpicture}
  \end{center}
  
%   \bibliographystyle{apacite}
%   \bibliography{citas}
  
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .