1

I am running into the following problem and hope that you can help me as my dead line is just around the corner and suddenly i have got this problem. I am using Texmaker with Miktex and i try to compile pdflatex. I am creating diagramms from tables with pfgplots and I create a legend and want to display it outside of the diagram. I am using the legend to name tool and \ref{} to it. This works for most of my diagrams fine but for a reason i dont understand for some not. The error occures always during the second compilation. Attached are my code and the passage from the log file.

Code:

\begin{figure}[H]
\begin{center}
    \begin{tikzpicture}
        \begin{axis}[               
            smooth,
            width= \textwidth,
            height= 0.5 * \textwidth,
            xmin={-2},
            xmax={2},
            %ymin={-2},
            %ymax={2},
            xlabel={$\xi ~=~ \nicefrac{y}{b}$},
            ylabel={$S_{P1}$, $S_{P2}$, $S_{P3}$, $S_{P4}$, $P_k$},
            legend columns=-1,
            legend entries={$S_{P1}$;, $S_{P2}$;, $S_{P3}$;, $S_{P4}$;, $P_k$,}, 
            legend to name= pkb,
        ]           
        %\addplot coordinates{(-2.1,0)};
        %\addplot coordinates{(-2.1,0)};            
        %\addplot coordinates{(-2.1,0)};                        
        \addplot table[x=xi, y=SP1, col sep=semicolon]{BudgetK.csv};    
        \addplot table[x=xi, y=SP2, col sep=semicolon]{BudgetK.csv};    
        \addplot table[x=xi, y=SP3, col sep=semicolon]{BudgetK.csv};    
        \addplot table[x=xi, y=SP4, col sep=semicolon]{BudgetK.csv};
        \addplot table[x=xi, y=PK, col sep=semicolon]{BudgetK.csv};                 
        \addplot [black,mark=none] coordinates{(-2.1,0) (2.1,0)}; 
        \end{axis}
    \end{tikzpicture}
\ref{pkb}
\end{center}
\caption{Components of $P_k$}
\label{fig:pkb}

\end{figure}

! Missing } inserted. } l.1047 \ref{pkb}

I've inserted something that you may have forgotten. (See the above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear.

! Missing } inserted. } l.1047 \ref{pkb}

I've inserted something that you may have forgotten. (See the above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear.

! Missing \cr inserted. \cr l.1047 \ref{pkb}

I'm guessing that you meant to end an alignment here.

! Misplaced \cr. \cr

l.1047 \ref{pkb}

I can't figure out why you would want to use a tab mark or \cr or \span just now. If something like a right brace up above has ended a previous alignment prematurely, you're probably due for more error messages, and you might try typing `S' now just to see what is salvageable.

I am very thankful for any help. I am pretty much in dispair. Thanks

1
  • 1
    Welcome to TeX.SE! Please make your code snippet compilable!
    – Mensch
    Nov 23, 2018 at 15:02

1 Answer 1

2

Ok folks i figured it out my self. If anybody runs in the same problem one day:

It is required to add 'forget plot' in the options for the plot that is not displayed in the legend.

\addplot [black, mark=none, forget plot] coordinates{(-2.1,0) (2.1,0)};

Cheers.

You must log in to answer this question.

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