Sunday, September 4, 2011

Graphics xfig can edit

It is often necessary in teaching and writing to modify a plot of data or a graph of a function using xfig. For instance, I create eps figures from Matlab or wxMaxima, and I need to edit out unnecessary tick marks or tick mark labels. xfig can operate on *.fig files. So, you need to convert the eps file to a fig file. This blog post is just a shout-out to Linux for Research's short post about it. Find it here. Thanks, Linux for Research!

Thursday, September 1, 2011

Forcing LyX to open newer file formats

Sometimes you create LyX files on the newer version, say, on your office machine, and try to open them on an older version, say, at your home machine. In order to put off upgrading my whole system (long story), I can simply rewrite the header information on the file.

Make a backup of the old file.
Identify the first two lines, which should look like:

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413


Comment out those lines and add the following two lines above the now-commented-out lines

LyX 1.6.7 created this file. For more info see http://www.lyx.org/
\lyxformat 345


So that it reads

LyX 1.6.7 created this file. For more info see http://www.lyx.org/
\lyxformat 345

##LyX 2.0 created this file. For more info see http://www.lyx.org/
#\lyxformat 413


Note that when you open your new file you may receive error messages from LyX. You can ignore them at your own risk. If I see something serious I look more closely, but at the very least I can at least copy and paste my content into a new clean file from the older LyX.

Lastly, consider destroying the backup of the LyX file.

Monday, May 2, 2011

Deleting unwanted directories from Subversion

Here is the problem: I have svn-moved a whole bunch of files out from a directory tree that is being version-controlled by svn. E.g.

parent/dir_1/dir_A/file_1
parent/dir_1/dir_A/file_2
parent/dir_1/dir_B/file_3
parent/dir_1/dir_B/file_4
parent/dir_2/dir_A/file_5
parent/dir_2/dir_A/file_6
parent/dir_2/dir_B/file_7
parent/dir_2/dir_B/file_8

has become

parent/file_1
parent/file_2
parent/file_3
parent/file_4
parent/file_5
parent/file_6
parent/file_7
parent/file_8

Now I want to get rid of (remove from svn's version control and delete from the filesystem) the following directories

dir_1/
dir_1/dir_A/
dir_1/dir_B/
dir_2/
dir_2/dir_A/
dir_2/dir_B/

The way to do this so that you do not encounter conflict errors is like this:

user@computer>% cd parent
user@computer> svn delete dir_1
user@computer> svn delete dir_2
user@computer> svn update
user@computer> svn commit

If you try to skip the 'update' command, you will encounter conflict errors.

Sunday, April 24, 2011

Using Tagsistant

After installing Tagsistant we need to start it up and get it set up.

Make a directory that will contain tags:

user@computer> mkdir ~/Papers_tfs


(My pdf files are contained in a directory named Papers, so I append an tfs to denote that this is a tagsistant file system version of the original.)

To start Tagsistant:

user@computer> sudo tagsistant ~/Papers_tfs


Make some tags (note that "tags" are actually directories, and this explains why they are created using mkdir):

user@computer> mkdir ~/Papers_tfs/numerical_analysis
user@computer> mkdir ~/Papers_tfs/approximation_theory
user@computer> mkdir ~/Papers_tfs/orthogonal_polynomials
user@computer> mkdir ~/Papers_tfs/mathematics


Add some files, i.e. Tag your files:

user@computer> cp ~/Papers/paper_on_interpolation.pdf ~/Papers_tfs/numerical_analysis/
user@computer> cp ~/Papers/paper_on_interpolation.pdf ~/Papers_tfs/approximation_theory/
user@computer> cp ~/Papers/paper_on_interpolation.pdf ~/Papers_tfs/mathematics/
user@computer> rm ~/Papers/paper_on_interpolation.pdf
user@computer> cp ~/Papers/paper_on_Legendre_polynomials.pdf ~/Papers_tfs/numerical_analysis/
user@computer> cp ~/Papers/paper_on_Legendre_polynomials.pdf ~/Papers_tfs/orthogonal_polynomials/
user@computer> cp ~/Papers/paper_on_Legendre_polynomials.pdf ~/Papers_tfs/approximation_theory/
user@computer> cp ~/Papers/paper_on_Legendre_polynomials.pdf ~/Papers_tfs/mathematics/
user@computer> rm ~/Papers/paper_on_Legendre_polynomials.pdf


Note: Only one copy of paper_on_interpolation.pdf is stored is stored in ~/.tagsistant/archive/. This applies to paper_on_Legendre_polynomials.pdf, as well.

We can browse our files using tags now:

user@computer> ls -la ~/Papers_tfs/approximation_theory/AND/numerical_analysis/AND/orthogonal_polynomials/



and we would get:

paper_on_Legendre_polynomials.pdf

while

user@computer> ls -la ~/Papers_tfs/approximation_theory/AND/numerical_analysis/


produces:

paper_on_Legendre_polynomials.pdf
paper_on_interpolation.pdf

Shutting down the filesystem:

user@computer> sudo fusermount -u ~/Papers_tfs


Note: Your files are still available (in ~/.tagsistant/archive/ as mentioned above) even when tagsistant is not running.

Saturday, April 2, 2011

Installing Tagsistant on Ubuntu 10.10 Maverick Meerkaty

We need to compile this program from source. This can be scary but this is my experience and it was painless, luckily.

  1. Download the source code for the developer's website: http://www.tagsistant.net/ I put the zipped bundle in my local temp folder: ~/tmp/.
  2. Extract the contents into a local working folder: ~/tmp/Tagsistant/.
  3. Navigate to the folder with the source code.
  4. You will run './configure', 'make', and then 'make install'. But beware: any of these steps may halt and they will need to be re-run until they complete. The installation may not work unless you wait for the current step to be completed in full before proceeding to the next step. I encountered three things that went wrong in my installation: certain packages had not been installed, priviledges were not high enough, and certain folders could not be created. In each case read the messages carefully, and try to fix them in succession.
  5. During the './configure'-stage it complained that I did not have libfuse-dev and libsqlite3-dev . I used Synaptic to find and install each and whatever dependencies they asked for. The key part of the message here had the string: (I lost it.)
  6. During the 'make'-stage it complained that I did not have libgtk2.0-dev. I used Synaptic to find it and install it and whatever dependencies it requested. The key part of the message here had the string: gtk+-2.0 was not found.
  7. During the 'make install'-stage it complained that it could not make the folder /usr/local/share/pixmaps/tagsistant/ so I made it using 'sudo mkdir -p /usr/local/share/pixmaps/tagsistant/'. Upon re-running 'make install' it needed permission to make a file so I had to re-run using sudo: 'sudo make install'. After re-running this time, the installation completed.
  8. To make sure the program was known by my system I typed 'which tagsistant' and 'which tagman'. My system replied '/usr/local/bin/tagsistant' and '/usr/local/bin/tagsistant', respectively.
My next posts will give my experiences using tagsistant to tag pdf of academic papers and my experiences mirroring and synchronizing my tagged pdf files in the context of tagsistant.

Tuesday, May 4, 2010

Getting xfig, LaTeX, and LyX to work properly with each other

To get these three guys to cooperate is a hassle if you do not know the secrets.

In xfig, there are few things to remember:

  • Use the 'special' flag when creating text objects.
  • Use LaTeX fonts; 'default' works for me.
  • Use LaTeX code as you normally would. E.g. to enter the antiderivative of the sine function, use $\int \sin (x)$. LyX sometimes balks if slashes (\) are not preceded by empty space, which I do not understand. To place your LaTeX text objects in their correct location with respect to the graphical objects is not straightforward and may take several iterates (see below; I may post something about this intuitive though tedious process).
  • Export to 'Combined PDF/LaTeX (both parts)', though this post should apply equally to the eps format if you make the appropriate changes. If your xfig file is named foo.fig, this will output foo.pdf and foo.pdf_t by default. foo.pdf contains graphical objects without any text that had the 'special' flag on, while foo.pdf_t contains a call to \includegraphics{foo.pdf} and all the LaTeX commands necessary for superimposing the LaTeX onto the graphical objects.

To take care of the first two points, I launch xfig with

xfig -specialtext -latexfonts -startlatexFont default

In LaTeX and LyX you needs to add into your preamble the following:

\usepackage[pdftex]{graphics,color}

\DeclareGraphicsRule{.pdf_t}{pdf}{*}{}

\graphicspath{{path_to_your_graphics/}}

I do not understand why the 'color' package is necessary, but it is. The second line is to tell LaTeX how to handle the graphics extension .pdf_t. The last line is to tell the graphics package where to find graphics files. The trailing / is necessary as per the documentation of the graphics bundle. The alternative to adding the last line is to edit the

\includegraphics{foo.pdf}

line in foo.pdf_t to

\includegraphics{path_to_your_graphics/foo.pdf}

The problem with this is that you need to edit this file after every time you export foo.pdf and foo.pdf_t from xfig and you may need to adjust the LaTeX text objects and export your graphics several times.

At the point in the document where you want the graphic to appear, you can use

\input{path_to_your_graphics/foo.pdf_t}

If you are using LyX, enter this code using LaTeX input (ctrl-l on unix, or Insert -> TeX Code). If LaTeX can find your graphics (i.e. your graphics are in the TEXINPUTS path or kpathsea can find them) then you should be able to get away with

\input{foo.pdf_t}

for the last line, but I have not tried to get this to work.

Friday, May 1, 2009

Interactive Search and Replace in vi

I have found a useful command in vi to perform an interactive search and replace in vi. Suppose that you want to find the string trig and replace it with quart in almost every instance of a file: in such a way that you must interactively confirm which instances to replace and which to leave alone.

The way to do this is, for the above example, i.e. replace trig with quart, is:

:1,$s!trig!quart!cg

You can replace all three ! with some other character. This is useful, for instance, if your search string has a ! in it. The 1 denotes the line that you want to start searching and the dollar sign denotes the line that you want to end at. $ means the last line as per usual.