My gnuplot.plt is set up like this
set term cairolatex pdf
set output "data.tex"
set nokey
plot 'data.csv' using 1:2 with lines,
And I use the output from gnuplot in my latex like this
\begin{figure}
\input{data.tex}
\end{figure}
Which works fine and valid when compiles with lualatex, but if I add
set format x "%.0s 10^%S"
The generated data.tex gives this error when compiled
! Missing $ inserted.
<inserted text>
$
l.129 \gplbacktext
I did try to put \( \) around the \gplbacktext and the format-string, but that changed nothing.
My problem is that I don't understand how I can format my axes without latex compilation only giving me errors of missing $.
It would be nice to add \frac{x}{y} or \mu or some other pretty latex-magic to the labels.
The complete erronous data.tex-file from gnuplot looks like this:
% GNUPLOT: LaTeX picture with Postscript
\begingroup
\makeatletter
\providecommand\color[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package color not loaded in conjunction with
terminal option `colourtext'%
}{See the gnuplot documentation for explanation.%
}{Either use 'blacktext' in gnuplot or load the package
color.sty in LaTeX.}%
\renewcommand\color[2][]{}%
}%
\providecommand\includegraphics[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package graphicx or graphics not loaded%
}{See the gnuplot documentation for explanation.%
}{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
\renewcommand\includegraphics[2][]{}%
}%
\providecommand\rotatebox[2]{#2}%
\@ifundefined{ifGPcolor}{%
\newif\ifGPcolor
\GPcolortrue
}{}%
\@ifundefined{ifGPblacktext}{%
\newif\ifGPblacktext
\GPblacktexttrue
}{}%
% define a \g@addto@macro without @ in the name:
\let\gplgaddtomacro\g@addto@macro
% define empty templates for all commands taking text:
\gdef\gplbacktext{}%
\gdef\gplfronttext{}%
\makeatother
\ifGPblacktext
% no textcolor at all
\def\colorrgb#1{}%
\def\colorgray#1{}%
\else
% gray or color?
\ifGPcolor
\def\colorrgb#1{\color[rgb]{#1}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
\expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
\expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
\expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
\expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
\expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
\expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
\expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
\expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
\else
% gray
\def\colorrgb#1{\color{black}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color{black}}%
\expandafter\def\csname LT1\endcsname{\color{black}}%
\expandafter\def\csname LT2\endcsname{\color{black}}%
\expandafter\def\csname LT3\endcsname{\color{black}}%
\expandafter\def\csname LT4\endcsname{\color{black}}%
\expandafter\def\csname LT5\endcsname{\color{black}}%
\expandafter\def\csname LT6\endcsname{\color{black}}%
\expandafter\def\csname LT7\endcsname{\color{black}}%
\expandafter\def\csname LT8\endcsname{\color{black}}%
\fi
\fi
\setlength{\unitlength}{0.0500bp}%
\ifx\gptboxheight\undefined%
\newlength{\gptboxheight}%
\newlength{\gptboxwidth}%
\newsavebox{\gptboxtext}%
\fi%
\setlength{\fboxrule}{0.5pt}%
\setlength{\fboxsep}{1pt}%
\begin{picture}(7200.00,4320.00)%
\gplgaddtomacro\gplbacktext{%
\csname LTb\endcsname%
\put(1155,595){\makebox(0,0)[r]{\strut{}$-0.00016$}}%
\csname LTb\endcsname%
\put(1155,1035){\makebox(0,0)[r]{\strut{}$-0.00014$}}%
\csname LTb\endcsname%
\put(1155,1475){\makebox(0,0)[r]{\strut{}$-0.00012$}}%
\csname LTb\endcsname%
\put(1155,1915){\makebox(0,0)[r]{\strut{}$-0.0001$}}%
\csname LTb\endcsname%
\put(1155,2355){\makebox(0,0)[r]{\strut{}$-8\times10^{-5}$}}%
\csname LTb\endcsname%
\put(1155,2795){\makebox(0,0)[r]{\strut{}$-6\times10^{-5}$}}%
\csname LTb\endcsname%
\put(1155,3235){\makebox(0,0)[r]{\strut{}$-4\times10^{-5}$}}%
\csname LTb\endcsname%
\put(1155,3675){\makebox(0,0)[r]{\strut{}$-2\times10^{-5}$}}%
\csname LTb\endcsname%
\put(1155,4115){\makebox(0,0)[r]{\strut{}$0$}}%
\csname LTb\endcsname%
\put(1257,409){\makebox(0,0){\strut{}1 10^-6}}%
\csname LTb\endcsname%
\put(1826,409){\makebox(0,0){\strut{}11 10^-6}}%
\csname LTb\endcsname%
\put(2396,409){\makebox(0,0){\strut{}21 10^-6}}%
\csname LTb\endcsname%
\put(2965,409){\makebox(0,0){\strut{}31 10^-6}}%
\csname LTb\endcsname%
\put(3534,409){\makebox(0,0){\strut{}41 10^-6}}%
\csname LTb\endcsname%
\put(4103,409){\makebox(0,0){\strut{}51 10^-6}}%
\csname LTb\endcsname%
\put(4673,409){\makebox(0,0){\strut{}61 10^-6}}%
\csname LTb\endcsname%
\put(5242,409){\makebox(0,0){\strut{}71 10^-6}}%
\csname LTb\endcsname%
\put(5811,409){\makebox(0,0){\strut{}81 10^-6}}%
\csname LTb\endcsname%
\put(6381,409){\makebox(0,0){\strut{}91 10^-6}}%
}%
\gplgaddtomacro\gplfronttext{%
\csname LTb\endcsname%
\put(144,2355){\rotatebox{-270}{\makebox(0,0){\strut{}Bias Currents [A]}}}%
\csname LTb\endcsname%
\put(4075,130){\makebox(0,0){\strut{}M1 width [um]}}%
}%
\gplbacktext
\put(0,0){\includegraphics{thresholdReferenceCurrentSource_W1vsW2_10samples}}%
\gplfronttext
\end{picture}%
\endgroup
My system is
This is LuaTeX, Version 1.0.4 (TeX Live 2017/Debian)
gnuplot 5.0 patchlevel 7
set format x '$%.0s \times 10^{%S}$'(note the dollars and single quotes) – Henri Menke Mar 24 '18 at 03:25^can only be used in math mode (indicated by$...$). The single quotes are used so that you don't have to escape backslashes ('\times'vs."\\times"). – Henri Menke Mar 24 '18 at 09:49\( \)and\[ \]enable math mode too? I never use$ ... $for anything and only\(\)etc – Federico Spaghetti Mar 24 '18 at 10:01\(and\)preferable to$? They are almost equivalent. It's basically a matter of taste. Here you can use them interchangably. – Henri Menke Mar 24 '18 at 10:11\( \)around the format strings and that did not work, but using$$worked. – Federico Spaghetti Mar 24 '18 at 10:26set format x '\(%.0s \times 10^%S\)'works perfect for me, as doesset format x "\\(%.0s \\times 10^%S\\)". – Henri Menke Mar 25 '18 at 02:41