1

I have no idea what is going wrong here: The error arose all of a sudden!

\documentclass[12pt,twoside]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{matrix,shadings,arrows,decorations.markings,decorations.pathmorphing}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={
            rectangle,
            draw=black,
            align=center,
                   },


    }
        }


\begin{document}

Hello World...
\begin{table}
\centering
\begin{tikzpicture}
\matrix[table, ampersand replacement=\&] (TabA1)
{
A1 \& A2 \\
B1 \& B2 \\
};
\end{tikzpicture}
\caption{Glossary}
\label{tabA1}
\end{table}



\end{document}

1 Answer 1

2

The problem are the empty lines in your \tikzset macro. The following works:

\documentclass[12pt,twoside]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{matrix,shadings,arrows,decorations.markings,decorations.pathmorphing}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={
            rectangle,
            draw=black,
            align=center,
        },
    }
}


\begin{document}

Hello World...
\begin{table}
\centering
\begin{tikzpicture}
\matrix[table, ampersand replacement=\&] (TabA1)
{
A1 \& A2 \\
B1 \& B2 \\
};
\end{tikzpicture}
\caption{Glossary}
\label{tabA1}
\end{table}



\end{document}
4
  • Hm...thx..why does this happen? I mean a blank line shouldn't be a problem actually!?!
    – Diger
    Aug 16, 2017 at 17:39
  • @Diger they are. In many macros (those which aren't long), empty lines are forbidden. This is due to the fact that empty lines are the same as \par and short macros can't contain a \par. You can comment out the empty lines with a leading % if you want the visual effect in your source files, though. % does comment out everything in the same row after it (including the newline) and all leading spaces in the next line.
    – Skillmon
    Aug 16, 2017 at 17:40
  • Thx. Another question regarding tikzset: How do I color all cell/nodes in gray? I tried: rows /. style={nodes={fill=gray!10, text=black}} but it doesnt work... Also I can not add fill=!gray!10 in the nodes above (where rectangle, draw=black.... is in)
    – Diger
    Aug 16, 2017 at 17:52
  • @Diger if it's another question, you might open another question.
    – Skillmon
    Aug 16, 2017 at 18:00

You must log in to answer this question.

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