1

I am trying to graph a rational trig function using tikz/pgfplots and got the error that it ran out of memory. I then changed my pdflatex line in TexMaker to "pdflatex -shell-escape name.tex" and tried to compile, and while I haven't run into a memory issue yet, it is still compiling after about 15 minutes. Is there something I can do about this or do I just need to let it run overnight?

\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{amssymb}
\usepackage{verbatim,amsfonts, colonequals, amsthm, amsmath, mathrsfs, amscd, pgfplots,multicol,geometry}
\usepackage{gensymb,tikz}
\usetikzlibrary{arrows}
\usepgfplotslibrary{external} 
\tikzexternalize

\geometry{textwidth=6.3in,textheight=9in}

\parindent=0in
\pagestyle{empty}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=.75]
\begin{axis}
\addplot[domain=-4:4, samples=128] {cos(x)/(2+sin(x))};
\end{axis}
\end{tikzpicture}
\end{center}

\end{document}

EDIT: I didn't end up using the deg option as I actually wanted radians, but the issue was with the -shell-escape externalization. If anyone runs into this issue, the solution for my problem was reaming the file so that it has no spaces.

1

Which of the many style files you include make your minimal working example minimal. Apart from that, there are two issues: domain:-4:-4 doesn't make too much sense and probably you want to convert the arguments of the trigonometric functions. This works:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\usepgfplotslibrary{external} 
\tikzexternalize

\pagestyle{empty}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=.75]
\begin{axis}
\addplot[domain=-4:4, samples=128] {cos(deg(x))/(2+sin(deg(x)))};
\end{axis}
\end{tikzpicture}
\end{center}

\end{document}
  • The styles are leftover from the main file I am using, I simply forgot to delete them. Also, the -4:-4 was a typo and it should be -4:4. I've tried running your example and i'll still stuck compiling for what seems to be an unusual amount of time. – JohnC Mar 25 '18 at 3:51
  • @JohnC Interesting. On my machine it takes less than a second. Are you compiling with -shell-escape? (I am using pdflatex -shell-escape.) Do the other documents compile on your machine? – marmot Mar 25 '18 at 3:57
  • "pdflatex -shell-escape Trig Graph.tex" where Trig Graph is the name of this example file I am using. My other tex documents compile just fine when I am using the normal "pdflatex -synctex=1 -interaction=nonstopmode %.tex" – JohnC Mar 25 '18 at 4:11
  • 1
    @JohnC I hope that there is not as space in your prompt. If yes, try pdflatex -shell-escape Trig\ Graph.tex, i.e. add a backslash, since otherwise the pdflatex will try to compile Trig.tex. – marmot Mar 25 '18 at 4:13
  • I can't get your suggestion to work with a space in the file name but if I change the file to Trig.tex and compile, it works. Any idea why it won't run even when using backslashes? – JohnC Mar 25 '18 at 4:49

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.