# How to clean up .table and .gnuplot using latexmk

I'm using latexmk as my building assistance. I'm also trying to use it as the clean-up contractor... In .latexmkrc I added:

$pdf_previewer = "open -a /Applications/Skim.app";$clean_ext = "rel paux lox pdfsync out bbl %R.run.xml %R.table %R.gnuplot";
$pdflatex = 'pdflatex -8bit -etex -shell-escape -file-line-error -halt-on-error -synctex=1 %O %S';$new_viewer_always [0];
$pvc_view_file_via_temporary [1];  so it will remove the tex_name.func_name.table and tex_name.func.gnuplot file types in addition to the defaults. Unfortunately, it doesn't work. When I run latexmk -c, this is the first output's line (I don't know if it is related): Useless use of array element in void context at (eval 12) line 5, <GEN0> chunk 1.  And these files stay in the directory. How can I make them gone? ## Edit: As @N.N. suggested I corrected the mistake in the last two code lines. As for the main issue of this question, I have to clarify the case. Compiling my document produces several files all having the following filename pattern: tex_main_name.function_name.gnuplot and similarly tex_main_name.function_name.table. I want latexmk -c to remove all of them. Therefore, using func_name.table in the latexmkrc will only remove two files. I hope the problem is clearer now. ## Edit 2: As @N.N. asked, here's a WME: \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} % Function \begin{scope}[domain=0.9:5.5,samples=200] \draw[<->,color=blue,line width=2pt] plot[id=func1] function{(x*x+x+1)/(x*x)} node[right] {$f(x)$}; \end{scope} \begin{scope}[domain=0.9:5.5,samples=200] \draw[<->,color=blue,line width=2pt] plot[id=func2] function{-(x*x+x+1)/(x*x)} node[right] {$f(x)$}; \end{scope} \end{tikzpicture} \end{document}  Compiling this code generates two files, namely file_name.func1.table and file_name.func2.gnuplot. I want that latexmk -c will remove these two files. - The error message indicates that there was an error in the Perl code in your .latexmkrc file. There should be some lines of context which may help to localize the error. It would be useful if you added this to the quote of the error message. More importantly, you should post the whole of your .latexmkrc file. The error is almost certainly somewhere other than the line from .latexmkrc you posted; that line is error free. – John Collins Jan 16 '12 at 20:13 @JohnCollins: Thanks for your comment. I didn't want to pollute the question. Now, I added all the complete .latexmkrc. Thanks again. – Dror Jan 17 '12 at 6:26 @Dror Could you please provide a full test case, i.e. a minimal TeX file that produces the .gnuplot and .table files that you want cleaned up. – N.N. Jan 17 '12 at 9:41 @Dror For me your example generates test.func1.table and test.func1.gnuplot (i.e. func1 and not func2). Anyway I have updated my answer to cover it. – N.N. Jan 17 '12 at 13:11 @Dror: Have you solved the problem? - I would like to use the solution. What you want is not $clean_ext = "%R.table %R.gnuplot"; but $clean_ext = "%R.*.table %R.*.gnuplot"; - but the wildcard * does not work:o( – Hans-Peter E. Kristiansen Feb 21 '12 at 1:30 ## 2 Answers This is not an answer, but an email from John Collins, saying that it will be possible in the future. Good idea. Unfortunately, it somewhat conflicts with another request, which is to allow the patterns in$clean_ext to be regular expressions (regexps). The wildcard idea is easier to implement, but the regexp idea gives finer control over the files to be deleted, which is needed in some situations.

In any case, the suggestion of allowing wildcards or regexps in the patterns is on my list of future enhancements.

John

Hans-Peter E. Kristiansen wrote: Tank you for a wonderful tool - latekmk. Can I suggest an improvement: In line 7016 add "glob" to the unlink command, to make it possible to use wildcards in the rc file like this: $clean_ext .= '%R.*.gnuplot'; - Please update this once it gets updated. – N.N. Feb 21 '12 at 17:48 @N.N.: I am not 100% sure, what you mean? - is it to say that I should delete this post, once the real answer is possible and posted? – Hans-Peter E. Kristiansen Feb 21 '12 at 21:46 No no, I just meant that it would nice if you updated your answer once the feature is implemented to reflect that. – N.N. Feb 22 '12 at 6:13 @N.N.: I will try to answer the question, when a solution is possible, but I do not know when - and I have no advantage over others to know. – Hans-Peter E. Kristiansen Feb 22 '12 at 18:25 @Hans-PeterE.Kristiansen: Is there some update regarding this issue? – Dror Aug 17 '12 at 6:14 You have not used the correct syntax for the last two lines in your .latexmkrc. What you seem to have done is to have copied the last two lines in your .latexmkrc from the latexmk manual in which the variables are listed along with their default value in square brackets. The correct syntax is roughly as follows (see the manual for details): $variable_name = value;


$new_viewer_always = 0;$pvc_view_file_via_temporary = 1;

$clean_ext = "out %R-blx.bib";  in an initialization file will imply that when a clean-up operation is specified, not only is the standard set of files deleted, but also files of the form FOO.out and FOO-blx.bib, where FOO stands for the basename of the file being processed (as in FOO.tex). So if you have a file named test.tex and which when it is compiled generates test.func1.gnuplot and test.func1.table and you want latexmkrc to clean out these, then you should add func1.table and func1.gnuplot to the variable $clean_ext. In some of my tests of other plots also test.pgf-plot.gnuplot and test.pgf-plot.table were generated. Thus, to cover all cases you should set the variable as follows:
$clean_ext = "func1.gnuplot func1.table pgf-plot.gnuplot pgf-plot.table";  - Thanks for the correction. The new version indeed doesn't produce error message, but still latexmk -c it won't remove the *.*.table and *.*.gnuplot. – Dror Jan 17 '12 at 8:15 How can I handle the case where test.func1.* and test.func2.* etc. were generated? – Dror Jan 17 '12 at 14:49 @Dror Have you got an actual case where test.func2.* is generated? I tried to use wild cards, such as *, in $clean_ext but it seem that they are not supported nor documented so the only solution to do this with $clean_ext seems to be adding a phrase for each. Thus, if only a small number of test.funcn.* is generated you can add a phrase corresponding to each n to $clean_ext. –  N.N. Jan 17 '12 at 14:54
I do get more then one pair of the form above. Add another plot and have something different then id=func1. See my edit to the TeX example. Anyway, in this case, I guess this is the end. Thanks –  Dror Jan 17 '12 at 15:02