2

I have two documents, with identical preambles, and for some reason path decorations work in one document and not the other. Lualatex keeps complaining that ! Undefined control sequence. <argument> \pgfdecoratedangle and I can't figure out why. It doesn't matter what decoration I use, whether I apply it for a partial path or a whole path, it just spits out that error.

Here's the entire document:

% vim: ft=tex
\RequirePackage{luatex85,shellesc}
\documentclass{scrartcl}

%% I use KOMA-script as I find it gives total control over a document structure.
%% Memoir would probably achieve the same results with marginally less pain, but
%% I'm not entirely sure I want to spend the time learning the other major custom
%% page classes.

%% KOMA options
\KOMAoption{cleardoublepage}{empty}
\KOMAoption{DIV}{10}
\KOMAoption{draft}{false}
\KOMAoption{fontsize}{10pt}
\KOMAoption{headings}{small}
% \KOMAoption{open}{right}
\KOMAoption{paper}{a4}
\KOMAoption{parskip}{half}
\KOMAoption{twoside}{false}
\KOMAoption{captions}{signature}
\KOMAoption{titlepage}{false}
\KOMAoption{abstract}{false}

\usepackage{listings}

%% e-TeX tools
\usepackage{etoolbox}

%% Subfiles for shared preambles
\usepackage{subfiles}

\usepackage{polyglossia}
\setdefaultlanguage[variant=australian]{english}

%% Colours - put this before typography so additional named colours can be defined.
\usepackage[table]{xcolor}
\definecolor{rmitred}{HTML}{DC241F}
\definecolor{rmitblue}{HTML}{341FDC}

\definecolor{red}{HTML}{DC291E}
\definecolor{blue}{HTML}{04588A}
\definecolor{orange}{HTML}{FA6B00}
\definecolor{green}{HTML}{038130}
\colorlet{wood}{brown!80!gray}
\colorlet{steel}{blue!20!gray}

\colorlet{tabledarkrow}{gray!12.5}
% \colorlet{tablelightrow}{gray!0}

%% Typography Settings
\usepackage[protrusion,expansion]{microtype}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{xunicode}
% xltxtra is not used with LuaTeX
% \usepackage{xltxtra}

%% Maths typography — re-enable these if we need maths support
\usepackage{physics}
\usepackage{mathtools}
\usepackage{unicode-math}

%% Use this to set up the headers and footers in the pages later on. 
%% Note that I will need to rework the code for that, as \makeatletter is ugly
\setkomafont{pagehead}{\small\sffamily\color{red}\selectfont}
\setkomafont{pagenumber}{\small\sffamily\color{black}\selectfont}

\usepackage[automark,nouppercase]{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\lohead{\thetitle}
\rohead{\theauthor}
\cfoot{\pagemark}

\setkomafont{title}{\Huge\sffamily\bfseries\color{red}}
\setkomafont{titlehead}{\color{gray}\large\sffamily}
\setkomafont{author}{\small\itshape}
\setkomafont{publishers}{\usefontofkomafont{author}}
\setkomafont{date}{\small}
\setkomafont{disposition}{\sffamily}
\setkomafont{section}{\sffamily\Large\bfseries}
\setkomafont{subsection}{\sffamily\large\bfseries}
\setkomafont{subsubsection}{\sffamily\bfseries}
\setkomafont{descriptionlabel}{\normalfont\bfseries}

\renewcommand{\sup}[1]{\textsuperscript{#1}}
\newcommand{\sub}[1]{\textsubscript{#1}}

% \usepackage{standalone}
\usepackage{tikz}
% \usepackage{pgfplots}
% \usepackage{pgfplotstable}
% \pgfplotsset{compat=1.13}

% Lua math library seems to clash with tikz decorations
\usepgflibrary{luamath}
\pgfkeys{pgf/luamath=parser}

\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{intersections}
\usetikzlibrary{positioning}
\usetikzlibrary{external}
\usetikzlibrary{patterns}
\usepgflibrary{arrows.meta}
\usetikzlibrary{bending}
\usetikzlibrary{angles}

% \tikzexternalize[prefix=tikz/,shell escape=-enable-write18]
\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzset{
  % Defines a custom style which generates BOTH, .pdf and .png export
  % but prefers the .png on inclusion.
  %
  % This style is not pre-defined, you may need to copy-paste and
  % adjust it.
  png export/.style={%
    external/system call/.add=%
    {}
    ; convert -density 300 -transparent white "\image.pdf" "\image.png",
  },
  png images/.style={%
    external/system call/.add=%
    {}
    ; convert -density 300 -transparent white "\image.pdf" "\image.png",
    % Don't need this as we're keeping the PDF in the document
    /pgf/images/external info,
    /pgf/images/include external/.code={%
      \includegraphics
      [width=\pgfexternalwidth,height=\pgfexternalheight]
      {##1.png}%
    },
  }
}

\usepackage{siunitx}
\usepackage{cancel}
\sisetup{detect-all, per-mode=symbol}
\DeclareSIPostPower\fourth{4}

\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\makeatletter
\newlength{\questionbeforeskip}
\newlength{\questionafterskip}
\setlength{\questionbeforeskip}{1.0ex plus -1ex minus -0.25ex}
\setlength{\questionafterskip}{1ex plus 0.25ex}
\newlength{\answerskip}
\setlength{\answerskip}{0.25ex plus -0.125ex minus -0.125ex}

\addtotoclist{loq}
\newcommand{\listofloqname}{List of Questions}
\newcommand{\listofquestions}{\listoftoc{loq}}
\setuptoc{loq}{sectionatlist}

\newcounter{question}[section]

\newcommand{\questionautorefname}{question}
\DeclareRobustCommand{\question}[2]{%
  \refstepcounter{question}%
  \addxcontentsline{loq}{section}{Question~#1}
  \pdfbookmark{Question~#1}{question:\thesection.\thequestion}
  {\usekomafont{subsection}{\par\vspace\questionbeforeskip Question~#1.}\par}
  {\itshape #2}\par\vspace\questionafterskip
}%
\newcommand{\answer}{\par\vspace\answerskip{\usekomafont{subsubsection}{Answer}}\par\vspace\answerskip}

\def\toclevel@question{4}
\makeatother

\usepackage[inline]{enumitem}
\setlist[enumerate]{label=(\alph*)}

% \setlist{noitemsep}
% \setlist[1]{labelindent=\parindent}
\newlist{subquestions}{enumerate}{3}
\setlist[subquestions]{leftmargin=*}
\setlist[subquestions,1]{label=\textup{\textbf{(\alph*)}}}
% Inline subquestions
\newlist{subquestions*}{enumerate*}{3}
\setlist[subquestions*]{itemjoin*={{, and }}}
\setlist[subquestions*,1]{label=\textup{\textbf{(\alph*)}}}

\newcommand{\qitem}[1]{\item{\textit{#1}}}
\newcommand{\qitemp}[1]{\qitem{#1}\\[0.5\parskip]}
\newcommand{\qitemq}[1]{\qitem{#1}\quad}

\usepackage{array}
\usepackage{tabulary}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{booktabs}

\newcolumntype{F}{>{\global\let\currentrowstyle\empty}}
\newcolumntype{f}{>{\currentrowstyle}X}
\newcolumntype{-}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}
% DEPRECATED
% TODO Find this in all documents and remove it
\newcommand{\SetRowStyle}[1]{\rowstyle #1}

% \newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{B}{>{\bfseries}} % Bold
\newcolumntype{K}{>{\scshape}}  % Smallcaps (German Kapitälchen)
\newcolumntype{I}{>{\itshape}}  % Italics
\newcolumntype{w}{<{\hspace{0.75em}}}  % Wide column
\renewcommand{\arraystretch}{1.25}
\renewcommand{\tabcolsep}{0.5em}

\usepackage{floatrow}

%% Penalties
\hyphenpenalty=2500
\tolerance=500
\widowpenalty=1500
\clubpenalty=1500

% Metadata goes here
\titlehead{A University}
\subject{The Subject}
\title{Homework 1}
\author{The Author}
\date{\today}

\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother

\usepackage{hyperref}
\hypersetup{
  pdfauthor={The Author},
  pdftitle={Homework 1},
  colorlinks=false,
hidelinks}
\usepackage[all]{hypcap}

%% Define all TikZ styles here
\tikzset{%
  information text/.style={xshift=0.30\textwidth, every node/.style={right, text width=0.70\textwidth, inner sep=1ex}},
  %
  my axes/.style={node font=\small, every node/.style={fill=white, fill opacity=0.0, text opacity=1}},
  important line/.style={very thick},
  cross section/.style={draw, line width=0.5pt, blue, fill=blue!40!white, every node/.style={node font=\footnotesize, color=black}},
  shape outline/.style={draw, line width=0.5pt, blue, fill=blue!20!white, every node/.style={node font=\footnotesize, color=black}},
  segment boundary/.style={draw, line width=0.5pt, dashed},
  dim edge/.style={densely dashed, line width=0.5pt, shorten >= -2.5mm, color=black!75!white},
  dim length/.style={draw, line width=0.5pt, arrows={Stealth-Stealth}, every node/.style={anchor=mid, midway, fill=white, node font=\footnotesize, inner sep=1pt},
  },
  translucent node/.style={fill opacity=0.5, text opacity=1},
  translucent shape/.style={fill opacity=0.75},
  rough edge/.style={decorate, decoration={random steps, segment length=2mm, amplitude=0.5mm}},
  % rough edge/.style={decorate, decoration={zigzag}},
  label/.style={every node/.style={anchor=mid, midway, inner sep=2pt, circle, fill=white, fill opacity=0.375, text opacity=1}},
  % png export,
}

\begin{document}

\maketitle

\question{6--20}{Locate the centroid $(\bar x, \bar y)$ for the angle's cross-sectional area:}
\begin{center}
  % \tikzexternaldisable
  \tikzsetnextfilename{homework-1-6-20}
  \begin{tikzpicture}

    \begin{scope}[my axes]
      \draw[->] (0, 0) -- (6, 0) node[right] {$x$} coordinate(x axis);
      \draw[->] (0, 0) -- (0, 5) node[above] {$y$} coordinate(y axis);
    \end{scope}

    \fill [fill=green!50!white]
      (0, 0) -- (4, 0) -- (4, 1) -- (1, 1) -- (1, 3) -- (0, 3) -- cycle;
    \path [fill=green!35!white]
      decorate[rough edge]{(0.75, 4)  -- (1.75, 4)} -- (1, 3) -- (0, 3) -- cycle
      decorate[rough edge]{(1.75, 2)  -- (4.75, 2)} -- (4, 1) -- (1, 1) -- cycle;
    \fill [fill=green!65!white]
      decorate[rough edge]{(1.75, 4)  -- (1.75, 2)} -- (1, 1) -- (1, 3) -- cycle;
    \fill [fill=green!65!white]
      decorate[rough edge]{(4.75, 2)  -- (4.75, 1)} -- (4, 0) -- (4, 1) -- cycle;
    \draw [green!10!white, line width=0.5pt]
      (0, 3) -- (1, 3) -- (1, 1) -- (4, 1) -- (4.75, 2)
      (1, 3) -- (1.75, 4)
      (4, 0) -- (4, 1);
    \draw [green, line width=0.5pt]
      (0.75, 4) -- (0, 3) -- (0, 0) -- (4, 0) -- (4.75, 1)
      (1, 0) -- (1, 1) -- (1.75, 2);

    \begin{scope}[my axes]
      \draw[->] (1.5, 1.9) -- (6, 1.9) node[right] {$x'$};
      \draw[->] (1.5, 1.9) -- (1.5, 5) node[above] {$y'$};
      \fill (1.5, 1.9) circle [radius=0.5mm];
      \node at (1.75, 2.15) {$C$};
    \end{scope}

    \path[label] (0, 0) -- (1, 3) node {1};
    \path[label] (1, 0) -- (4, 1) node {2};

    \draw[dim edge] (0, 0) -- (-0.5, 0);
    \draw[dim edge] (0, 3) -- (-0.5, 3);
    \draw[dim length] (-0.5, 0) -- (-0.5, 3) node {150};

    \draw[dim edge] (0, 0) -- (0, -0.5);
    \draw[dim edge] (1, 0) -- (1, -0.5);
    \draw[dim edge] (4, 0) -- (4, -0.5);
    \draw[dim length] (0, -0.5) -- (1, -0.5) node {50};
    \draw[dim length] (1, -0.5) -- (4, -0.5) node {150};

    \draw[dim edge] (4, 1) -- (5, 1);
    \draw[dim length] (5, 0) -- (5, 1) node {50};

    \draw[dim length] (5.5, 0) -- (5.5, 1.9) node {$\bar y$};
    \draw[dim length] (0, 4.5) -- (1.5, 4.5) node {$\bar x$};

    \node[above right, text width=3cm, node font=\itshape\small] at (2.5, 2.5) {All dimensions in \si{\mm}};


  \end{tikzpicture}
\end{center}
\answer
Divide the area into its composite shapes.
\begin{equation*}
  \begin{array}{l l l l l l}
    \toprule
    \text{Segment} & \text{Area} & \tilde x & \tilde y & \tilde x A & \tilde y A \\
    \midrule
    \multirow{2}{*}{1} 
    & 50 × 150 & \tfrac{1}{2} × 50 
    & \tfrac{1}{2} × 150 
    & 7500 × 25 
    & 7500 × 75 \\

    & =\SI{7500}{\square\mm} 
    & =\SI{25}{\mm} 
    & =\SI{75}{\mm} 
    & =\SI{187500}{\cubic\mm} 
    & =\SI{562500}{\cubic\mm} \\[0.75\parskip]

    \multirow{2}{*}{2} 
    & 50 × 150 
    & \tfrac{1}{2} × 150 + 50
    & \tfrac{1}{2} × 50 
    & 7500 × 125 
    & 7500 × 25 \\

    & =\SI{7500}{\square\mm} 
    & =\SI{125}{\mm} 
    & =\SI{25}{\mm} 
    & =\SI{937500}{\cubic\mm} 
    & =\SI{187500}{\cubic\mm}\\

    \midrule
    \sum & = \SI{15000}{\square\mm} &&& = \SI{1125000}{\mm\cubed} & = \SI{750000}{\mm\cubed} \\
    \bottomrule
  \end{array}
\end{equation*}
\begin{align*}
  \bar x &= \frac{\sum \tilde x A}{\sum A} = \frac{\SI{1125000}{\mm\cubed}}{\SI{15000}{\mm\squared}} = \SI{75}{\mm} \\[\parskip]
  \bar y &= \frac{\sum \tilde y A}{\sum A} = \frac{\SI{750000}{\mm\cubed}}{\SI{15000}{\mm\squared}} = \SI{50}{\mm} 
\end{align*}


\end{document}

The tikzset command immediately before the start of the document is used to configure global TikZ styles I use in multiple separate drawings.

Weirdly enough, removing the luamath parser fixes it in the misbehaving document, but that doesn't account for why it works in the working document.

EDIT Here's a link to a truncated part of the full document: https://gist.github.com/zoqaeski/df78b4eadbb4f351db49750b2451df25

MWE

% emacs: ft=tex
\RequirePackage{luatex85,shellesc}
\documentclass{article}

\usepackage{tikz}

\ifx\directlua\undefined\else
% Lua math library seems to clash with tikz decorations
\usepgflibrary{luamath}
\pgfkeys{pgf/luamath=parser}
\fi

\usetikzlibrary{decorations.pathmorphing}

\makeatother
%% Define all TikZ styles here
\tikzset{%
  rough edge/.style={decorate, decoration={random steps, segment length=2mm, amplitude=0.5mm}},
}

\begin{document}

  \begin{tikzpicture}
    \path [fill=green!35!white]
      decorate[rough edge]{(0.75, 4)  -- (1.75, 4)} -- (1, 3) -- (0, 3) -- cycle;
\end{tikzpicture}

\end{document}
4
  • please make your document complete and generate the error rather than stop at begin{document} also if you can reproduce with less code please do so, for example I get errors ! The font "Museo" cannot be found. and ! LaTeX Error: File 'tableformat.sty' not found. is that font and that package needed to reproduce the problem if not please delete them from the preamble, if so, please give links to where they may be found, they are not in texlive. Oct 29, 2016 at 8:48
  • The tableformat.sty package is a custom one I use to allow me to define column types and styles. I've incorporated it (and removed the font definitions) in the document link.
    – Robbie
    Oct 29, 2016 at 9:27
  • 1
    No please don't link to an external document, fix the example inline. It's unreasonable to expect people to download external code and this question is archived forever and will not make sense if the document at that link changes. Oct 29, 2016 at 9:29
  • I added a more reasonable test document, it runs without error with pdftex and gives the error as described with luamath parser. looking.... Oct 29, 2016 at 10:50

1 Answer 1

1

At least on my machine, adding these line solve the question

\makeatletter
\def\pgfmathanglebetweenpoints#1#2{%
  \begingroup%
    \pgf@process{\pgfpointdiff{#1}{#2}}%
    \edef\pgf@marshall{\expandafter\noexpand\csname pgfmathatan2@\endcsname{\expandafter\Pgf@geT\the\pgf@y}{\expandafter\Pgf@geT\the\pgf@x}}%
    \pgf@marshall%
    \ifdim\pgfmathresult pt<0pt\relax% <-- All I added is this this \relax
      \pgfmathparse{\pgfmathresult+360}%
    \fi%
    \expandafter%
  \endgroup\expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult}%
}

It seems that without the \relax, TeX will try to read the next token \pgfmathparse and then after some bizarre expansion the corresponding \fi of this \ifdim has never been read.

And then TeX go back to the previous macro expansion, which is \pgf@decorate@processnextinputsegmentobject. Since there are plenty of \fi's, TeX will take one of them, reporting no error so far.

After a while TeX wants to use the value of \pgfdecoratedangle, which should be defined by \let\pgfdecoratedangle\pgfmathparse. But the definition is ignore when TeX is finding the \fi, so an undefined control sequence error emerges.

1
  • I also use tikz decorations among other tikz settings, this seems like a major problem for a user!
    – daaxix
    Feb 21, 2017 at 4:09

You must log in to answer this question.

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