rlkamalapurkar / bodeplot

LaTeX package to plot Bode diagrams
LaTeX Project Public License v1.3c
6 stars 1 forks source link

bodeplot + gnuplot + externalize #6

Closed mw88-personal closed 2 years ago

mw88-personal commented 2 years ago

I have been trying to use your bodeplot package together with external library of tikz and was facing problems (as is often the case with external, but this time, I believe your package is the cuplrit).

The example I have been running is this:

    \documentclass[]{standalone}

    \usepackage{tikz}
    \usepackage{pgfplots}
    \usepackage{bodeplot}

    \usetikzlibrary{external}

    \tikzexternalize[%
        prefix=tmp/,%
    ]

    \tikzset{
        external/only named=true,
        external/optimize=false,
        }

    \begin{document}

    \tikzsetnextfilename{customname}
    \BodeZPK{%
        z/0,{-0.1, -0.5}, {-0.1, 0.5},
        p/{{-0.5, -10}, {-0.5,10}},
        k/10
        }{0.01}{100}
    \end{document}

Of course, I created a writable temporary directory <project directory>/tmp/, where I expected the externalized pdf to reside in. However, no externalized pdf is generated.

The relevant <project directory>/tmp/customname.log states:

! I can't write on file `gnuplot/tmp/customname1.gnuplot'.

I can see, that during compilation, a directory <project directory>/gnuplot/ is created, but no subdirectory. This is unexpected, but I can act accordingly: Once I create <project directory>/gnuplot/tmp/ (same as the directory tree given to \tikzexternalie[prefix=]), everything runs fine, and the resulting pdf file is getting placed where I expected it to be: in <project directory>/tmp/customname.pdf.

This issue serves multiple prposes:

  1. I would like to point out, that the bodeplot package behaves oddly in the given scenario, and does not work out of the box.
  2. I would like to document my workaround for others.
  3. I would like to ask if this is actually the expected behaviour or if it would be sensible to make changes. I could not come up with a better directory tree structure on first thought, but perhaps there is a possibility to generate all the required directories under gnuplot?
  4. In any case, I suggest adding a description of this behaviour to the package documentation.

Thank you for this wonderful package, by the way.

rlkamalapurkar commented 2 years ago

Thank you for the detailed bug report.

I can add a class option, say external, to be used whenever bodeplot is used with externalize. With that class option, the bodeplot directory structure will be disabled, and the gnuplot temporary files will be stored in the same directory as the tikzexternalize prefix. Would that be an acceptable solution? The following file implements just that (change extension to sty), please let me know if it works as expected. If all is well, I will update the package. bodeplot1.0.8beta.txt

The best courses of action would be to find out why pgf is appending the tikzexternalize prefix to the gnuplot prefix and stop that from happening, but that is beyond my skill level.

mw88-personal commented 2 years ago

Hi @rlkamalapurkar , thank you for the response. As I wrote previously, I can understand the reasons for your choices, and I am not seeing a definitive way it should be. However, these troubles were actually nearly preventing me from continued use of external library.

I tried your attached package, and found it nicely placed all the auxiliary files from bodeplot inside my specified external directory. As I think of it now, this is very nice, as I do not have to ensure subdirectories exist, and as an external user, I know to ensure the external directories exist.

This new option is a nice addition, and provides another workaround.

Perhaps I can make a different suggestion: If your package bodeplot refrains from setting prefix in

 \tikzset{%
    gnuplot@prefix/.style={%
      id=\arabic{gnuplot@id},
      prefix=gnuplot/\jobname
    }%
  }

at all (and from creating the bodeplot subdirectory), then its behaviour would me more consistent with the usual latex packages: By default, all auxiliary files would be cluttered into the main working directory, and external would work as expected, as well as user-defined prefixes. Then, you could offer having a custom subdirectory for bodeplot via an option, if it is needed at all?

rlkamalapurkar commented 2 years ago

That sounds better, fixed now. Class option declutter will restore the original behavior with subfolders.