z·eeki·sh

tech log on gentoo, linux, and random stuff

Posts Tagged ‘tex

sed one-liner for extracting pictures included in a tex file

leave a comment »

When writing up tex manuscripts, I usually put related data/function plots under the same directory as the tex file, or some sub-dir like ‘figs/’. Often times though, many of them are never actually used in the tex file. while I have no problem with cluttering up my folders with unused plots, it is quite painful when you need to pick out those used plots, for example when tar-balling them to share with a colleague or submit it to some journal. Here is a one-liner to extract a list of used plots in a tex file:

sed -n 's/[^%]*includegraphics[^{]*{\([^}]*\)}.*/\1/p' draft.tex

NB:

  1. draft.tex is the desired tex file from which to extract the list of figures.
  2. The -n tells sed to suppress printing unless instructed to (which will be effected by the tailing /p.
  3. The [^%] will skip plots commented out.

Here is the shell command to generate a tarball containing all necessary files:
tar -cvvzf draft.tgz draft.tex *bbl *bst $(for f in `sed -n 's/[^%]*includegraphics[^{]*{\([^}]*\)}.*/\1/p' draft.tex`; do echo `basename $f .pdf`.pdf; done)

Advertisements

Written by zsh

January 20, 2013 at 11:42 am

Posted in /usr/bin

Tagged with , , ,

TeX capacity exceeded

leave a comment »

After the discovery of gnuplot’s tikz term, I have been using it for most of the plots I send to my advisor. A very nagging problem though is that when the number of data points is big, pdflatex would complain about “TeX capacity exceeded, sorry [main memory size = xxxx]” and refuse to compile. Today it has just come to a point I can’t stand this any more, so I did some googling and found a solution. Now TeX is a very messy system with fmt, sty, cnf files all over the place, so be sure to backup anything you touch in case something goes wrong.

Here’s a web page from JadeTeX that pointed me in the right direction, http://jadetex.sourceforge.net/#index-div-d18e113. The following solution is based on this.

  1. make changes to texmf.cnf. You may want to use `locate texmf.cnf’ to find where it is. Then in it, change `main_memory’ from 3000000 to say 8000000
  2. now regenerate latex.fmt for plain latex, or pdflatex.fmt for pdflatex. E.g., to recompile pdflatex.fmt:
    1. find where “pdflatex.ini” is
    2. cd to that path, then invoke “pdflatex -ini -progname=pdflatex pdflatex.ini”
      Notice that this is different from what’s in the JadeTeX webpage. You need to invoke “pdflatex” instead of “tex”
    3. now find where the original “pdflatex.fmt” is, back it up, and copy the generated “pdflatex.fmt” to there
  3. to regenerate “latex.fmt”, use “latex -ini -progname=latex latex.ini

Update@2011/06/08:

In gentoo, the proper way of fixing this once and for all is:

  1. Change the value of the corresponding field in file /etc/texmf/texmf.d/20sizes.cnf. This should persist through all future texliveupgrades.
  2. run texmf-update to regenerate the system-wide texmf.cnf
  3. run fmtutil-sys --all to regenerate the .fmt files

Update@2012/3/15:

alternatively one can compile with lualatex, which doesn’t seem to have a size limit

Written by zsh

February 23, 2011 at 2:37 pm

quick notes on using gnuplot’s lua terminal

with one comment

In gnuplot,

set term tikz fulldoc color solid createstyle
set output 'tmp.tex'
p x**2 tit '$x^2$'

then in shell,

pdflatex tmp.tex

NB:
(1) ‘createstyle’ is crucial, otherwise tex will complain about missing ‘gnuplot-lua-tikz.sty’. This doesn’t seem to be mentioned in the first several google results
(2) I have to comment out the ‘utf8x’ package in the resulting tmp.tex. That may just be a problem with my tex environment

Written by zsh

January 22, 2011 at 12:50 pm

Posted in /usr/bin

Tagged with , , ,