pgfplots not working with TexLive on Windows - latex

\begin{tikzpicture}
\begin{axis}
\addplot[color=red]{exp(x)};
\end{axis}
\end{tikzpicture}
%Here ends the 2D plot
\hskip 5pt
%Here begins the 3D plot
\begin{tikzpicture}
\begin{axis}
\addplot3[
surf,
]
{exp(-x^2-y^2)*x};
\end{axis}
\end{tikzpicture}
Gives the following error:
Package tikz: Sorry, the system call 'pdflatex -halt-on-error -interaction=batchmode -jobname "main-figure0" "\def\tikzexternalrealjob{main}\input{main}"' did NOT result in a usable output file 'main-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in 'main-figure0.log'. If you continue now, I'll try to typeset the picture.
And when looking in the log:
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2022.4.7) 8 FEB 2023 12:32
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**PATH/main.tex
(PATH/main.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24> (c:/texlive/2022/texmf-dist/tex/latex/base/report.cls
Document Class: report 2021/10/04 v1.4n Standard LaTeX document class
(c:/texlive/2022/texmf-dist/tex/latex/base/size11.clo
File: size11.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
(when compiling with --escape-shell):
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2022.4.7) 8 FEB 2023 13:22
entering extended mode
\write18 enabled.
%&-line parsing enabled.
**main.tex
(./main.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(c:/texlive/2022/texmf-dist/tex/latex/base/report.cls
Document Class: report 2021/10/04 v1.4n Standard LaTeX document class
(c:/texlive/2022/texmf-dist/tex/latex/base/size11.clo
File: size11.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
and later:
===== 'mode=convert with system call': Invoking 'pdflatex -halt-on-error -interaction=batchmode -jobname "main-figure0" "\def\tikzexternalrealjob{main}\input{main}"' ========
runsystem(pdflatex -halt-on-error -interaction=batchmode -jobname "main-figure0" "\def\tikzexternalrealjob{main}\input{main}")...disabled (restricted).
\openout3 = `main.auxlock'.
./0_abstract.tex:14: Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error -interaction=batchmode -jobname "main-figure0" "\def\tikzexternalrealjob{main}\input{main}"' did NOT result in a usable output file 'main-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in 'main-figure0.log'. If you continue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.14 \end{tikzpicture}
I have included the right packages etc.:
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
% We will externalize the figures
\usepgfplotslibrary{external}
\tikzexternalize
I have also tried running it with things such as:
--shell-escape main.tex
--enable-write18 main.tex
or adding
\tikzexternalize[shell escape=-shell-escape]
But this does not seem to work, everything does work correctly when I e.g. open it in Overleaf.
minimal reproducible example:
\documentclass[11pt,a4paper,oneside]{report}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
% We will externalize the figures
\usepgfplotslibrary{external}
\tikzexternalize
% Do not automatically indent text
\setlength\parindent{0pt}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[color=red]{exp(x)};
\end{axis}
\end{tikzpicture}
%Here ends the 2D plot
\hskip 5pt
%Here begins the 3D plot
\begin{tikzpicture}
\begin{axis}
\addplot3[
surf,
]
{exp(-x^2-y^2)*x};
\end{axis}
\end{tikzpicture}
\end{document}

Related

How to import a package in Latex3? The package is a ".sty" file

The first.sty file is below:
%\iffalse
%
%<*driver|package>
\RequirePackage{expl3}
%</driver|package>
%
%<*package>
\NeedsTeXFormat{LaTeX2e}[2022/5/13 v2.02 First latex project]
%</package>
%
%<*driver>
\documentclass[full]{l3doc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{jobname.dtx}
\end{document}
%</driver>
%\fi
%
%
% \begin{macro}{\second}
% this is an example of using l3 cs command
% \begin{macrocode}
\cs_new:Npn \second:n #1 { THIS IS SECONDCOMMAND #1 }
% \end{macrocode}
% \end{macro}
%
% \Finale
% \printindex
%\endinput
The first.tex file is below:
\documentclass[full]{l3doc}
\usepackage{first}
\title{First Project Document}
\author{Carlos}
\begin{document}
\maketitle
\section{Introduction}
There's not much more to say right here.
This is where the user documentation for the simple tree example goes. \first
\end{document}
The first.tex run in the TexShop on Mac. There are some issues below:
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./test.6.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-04-20>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/Users/focus/Library/texmf/tex/latex/latex3-packaging/first/first.sty
(/Users/focus/Library/texmf/tex/latex/l3kernel/expl3.sty
(/Users/focus/Library/texmf/tex/latex/l3backend/l3backend-pdftex.def))
/Users/focus/Library/texmf/tex/latex/latex3-packaging/first/first.sty:20: **Undef
ined control sequence.**
l.20 \cs
_new:Npn \second:n #1 { THIS IS SECONDCOMMAND #1 }
In the first.tex, import a package "first.sty". I separate the macro package "first.sty" from first.tex base on latex3's l3build file structure. So I focus on coding the macro in "first.sty".
The issue is that the "\second" do not recognize. Maybe need more syntax here. I am not sure which syntax it is. Please help me fix that.

Citation undefined on input even though they exist

Hi I'm using Overleaf for my dissertation and this warning started popping up recently:
Citation 'objprogen' on page 1 undefined on input line 8.
This citation is already created as seen below in the 'sources.bib' file:
#article{objprogen,
author={Guo, Wenzhong and Lin, Renjie and Wang, Shiping and Xiong, Neal},
booktitle={2018 9th International Symposium on Parallel Architectures, Algorithms and
Programming (PAAP)},
title={Object Proposal Generation for Unsupervised Object Localization},
year={2018},
volume={},
number={},
pages={235-242},
doi={10.1109/PAAP.2018.00046}}
This is my main.tex file:
\documentclass[a4paper]{article}
\usepackage{blindtext, graphicx}
\usepackage{csquotes}
\usepackage[hidelinks]{hyperref}
\usepackage{url}
\usepackage[style=authoryear-ibid,backend=biber]{biblatex}
\hyphenation{op-tical net-works semi-conduc-tor}
\bibliography{sources.bib}
\begin{document}
\title{Can image recognition systems be successfully integrated with existing VIN databases
irrespective of the vehicle manufacturer}
\author{myname}
\maketitle{}
\input{includes/01-Abstract}
\input{includes/02-Introduction}
\input{includes/03-Literature}
\input{includes/04-Methodology}
\input{includes/05-Findings}
\input{includes/06-Conclusion}
\input{includes/07-Appendix}
\end{document}
I had the same problem and solved it by adding \bibliographystyle{plain} (of course you could in principle use other styles). For me the structure of the tex file is the following
\documentclass[oneside, a4paper, onecolumn, 11pt]{article}
%%some packages%%
\begin{document}
%%% some stuff
\bibliographystyle{plain}
\bibliography{bibfile} %bibfile name without the .bib extension
\end{document}
So contrary to you the \bibliography is also inside the document environment.

"Error Producing PDF" when markdown contains a horizontal rule: --- or ***

When my Markdown file contains a horizontal rule --- or *** I receive an error regarding \Linethickness -> \Protect
I understand there have been issues with MiKTeX recently, however I am unsure whether they apply here.
I have been experiencing this issue since yesterday morning, when I was playing around trying to get the Lato font package to work with a set of Markdown files I need to convert to PDF. It had been working fine (asides from the font issue).
This could have happened when I updated MiKTeX, although at the time I hadn't realised that could be the case, as I was also playing with the templates, YAML, PS Script etc.
Since then I've been reading about the MiKTeX issue and I've tried further updates, updating package database, building formats, refreshing file name database and uninstalling and reinstalling. I have read the background in the comments section on GitHub but the suggestions there do not seem to have solved it for me, whereas they have for others.
This makes me question whether this is related, but I am relatively new to Tex, Markdown etc.
The original file was longer and more complex, but this Markdown
# Sample File
Test Test Test
---
Produces the same error
Error producing PDF.
! Missing number, treated as zero.
<to be read again>
\protect
\linethickness ->\protect
\linethickness
\setlength #1#2->#1 #2
\relax
\#rule ...#tempdimb {#2}\setlength \#tempdimc {#3}
\advance \#tempdimc \#temp...
l.362 ...nter}\rule{0.5\linewidth}{\linethickness}
Removing the --- allows the pdf to generate in both the above example and my more complex markdown file, even with templates.
I am unsure if linethickness is within the graphics package, when I look at package information I can't see anything that obviously indicates it is.
I would simply remove the offending lines but they are used throughout the remainder of the markdown files and I would prefer to find a fix, with your help, if possible!
Please could you let me know if I'm barking up the wrong tree with this recent MiKTeX issue or not, and if not, where I might be going wrong.
Many Thanks in advance.
Update:
I ran this command
pandoc -s sample.md -o sample.tex
to produce this tex:
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\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{
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1cm]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\date{}
\begin{document}
\setcounter{errorcontextlines}{40}
\hypertarget{sample-file}{%
\section{Sample File}\label{sample-file}}
Test Test Test
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
\end{document}
meanwhile, I tried this (as root in a latest RStudio Debian install):
~# sed 's,\\linethickness,0.5000000000pt,g' < pandoc/pandoc > /usr/lib/rstudio-server/bin/pandoc/pandoc
where the 1st pandoc/pandoc is a copy of the original from package. That keeps the same string length and valid number so that the binary won't break. That writes the hrule as:
\begin{center}\rule{0.5\linewidth}{0.5000000000pt}\end{center}
and MiKTeX seems fine with it (at least TeXworks compiles the pdf).
HTH
bye

Missing number treated as zero error when using titlesec package and tableofcontents

Whenever I use the package titlesec and later the command \tableofcontents I get the following error:
I created the following MRE below
! Missing number, treated as zero. <to be read again>}\tableofcontents
In the past this never happened, but since I installed MikTex on my new laptop, those lines below do not work anymore.
Removing the package titlesec seems to work, but I would rather know the actual reason for this problem.
\RequirePackage{fix-cm}
\documentclass[
%draft,
pdftex,
paper=a4,
%paper=portait, % Paper Setting
pagesize=auto,
fontsize=11pt, % Font Size
version=last, % Version
%headsepline, % Line after header
%footsepline, % Line before footer
]{scrartcl}
\KOMAoptions{parskip=true}
% Depth of content table
\usepackage{titlesec}
\begin{document}
\tableofcontents
\newpage
Test
\end{document}

gnuplot with texshop in osx

I have installed gnuplot through macports but when i compile my latex document in texshop it doesn't show the plots and I get these errors in the log file:
Package pgf Warning: Plot data file `tutorial.x.table' not found. on input line
17.
Package pgf Warning: Plot data file `tutorial.sin.table' not found. on input li
ne 19.
Package pgf Warning: Plot data file `tutorial.exp.table' not found. on input li
ne 21.
I'm just trying to compile this basic example:
% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
% GNUPLOT required
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot[id=x] function{x}
node[right] {$f(x) =x$};
\draw[color=blue] plot[id=sin] function{sin(x)}
node[right] {$f(x) = \sin x$};
\draw[color=orange] plot[id=exp] function{0.05*exp(x)}
node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}
\end{document}
Yes, you need to turn the .gnuplot files that tikz creates into the tables files. You have two choices for this:
you can run (pdf)latex with the additional command line switch --shell-escape, sometimes also called --enable-write-18, then gnuplot is run automatically for you. (You might not be comfortable with allowing arbitrary programs to be starte from within pdflatex, though.)
you can run gnuplot yourself on the test.exp.gnuplot, test.sin.gnuplot, test.x.gnuplot etc. files. Simply gnuplot test.exp.gnuplot should do it. (Can't verify here, since my gnuplot version is too old.)

Resources