# automated path for pgfplots grafics with standalone

Issue #41 new
Former user created an issue

Using pgfplots with standalone can be inflexible if you are loading data from files that has to be ploted. It would be nice if standalone could add the current path to pgfplots addplot so coping the file to a different location and use it again without modification would be possible.

Here a suggestion that I use successfully for two years now. The only requirement is that a datafile has to be located within the folder of the drawing or a subfolder.

```%Diese kleine Datei modifiziert das includestandalone Kommando des standalone Package, sodass pgfplots-Bilder, die externe Daten laden, den Pfad dynamisch erhalten. Bilder können so im Standalonemodus und eingebunden in eine andere Datei verwendet werden, ohne das händisch der Dateipfad der Daten geändert werden muss.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{standalonedatapath}

\makeatletter%
{\usepackage{currfile} %
\usepackage{ifthen} %
\ifthenelse{\equal{\currfiledir}{}}{\providecommand{\datapath}{.}}{\providecommand{\datapath}{\currfiledir}}}%
{\RequirePackage{standalone} %
\RequirePackage{xstring} % Wird zum Auftrennen des Pfads benötigt
\newcommand{\includestandalonewithpath}[2][]{ %
\begingroup %
\StrCount{#2}{/}[\matches] %
\StrBefore[\matches]{#2}{/}[\datapath] %
\includestandalone[#1]{#2} %
\endgroup %
} %Kommando für die Datenweitergabe an includestandalone
}
\makeatother%
\endinput
```

In pgfplots an addplot command would be modified to

```    \addplot[smooth,color=blue,very thick] table[x=Wellenlaenge, y=rel Intensitaet, col sep=semicolon]{\datapath/xyz.csv}
```

If the drawing is used alone the package has to be loaded as well to provide the datapath variable.

Wouldn't that be an enhancement of the standalone package?

```**\datapath**/xyz.csv
```

should be

```\datapath/xyz.csv
```

Sorry for that mistake. I am not that familiar with bitbucket

1. repo owner
• edited description