Skip to main content

Embedding tex in pdf figures

It's often required to include latex symbols in publication ready figures. For example Greek symbols in LaTex can be written as \alpha which appear as the actual alpha symbol when compiled.

The same effect can be embedded in figures and these figures can be separately compiled for convenience. This means that you don't have to create any intermediate files (such as pstex) in your actual tex file but rather have standalone pdf figures.

You need to have a few things in hand and this is done in Ubuntu (or any Linux system)
1. Dia
2. fig2pdf (sudo apt-get install fig2pdf) - this will install a whole range of other converters, fig2eps etc.
3. XFig (this will be installed from the fig2pdf command itself)
4. Latex (comes with the Ubuntu distribution)

OK. In Ubuntu you can test if everything is available by typing in the commands, e.g. if you type fig2pdf it should know the command and should tell you the usage.

Now we proceed to create a figure in Dia.



You see that this figure has a shape, text and latex special text which represents the alpha symbol.
Once you create the figure you should export it as a fig so that it can be opened/edited via the XFig software.


OK, now you should have saved your .dia file and you should've exported it to XFig format with the .fig extension.
You can also directly create .fig files via the XFig software itself but it's easier with Dia.

Now you should do the following steps to successfully convert this to a postscript or a pdf figure.
Here are the steps.

  1.  Convert fig to pstex
  2.  You should embed this pstex in a minimal .tex file
  3. Compile this tex file to produce the dvi  figures
  4. convert this .dvi figure to .ps via dvips
  5. Convert the .ps to pdf via epstopdf
  6. Clean the auxiliary files

OK, so we do it all in a script thanks to modified script take from here. :-)
We can easily use the pdfcrop tool which comes with tex live distribution to get rid of the white space around figures.


Comments

Popular posts from this blog

Detaching a process from terminal - exec(), system(), setsid() and nohup

Linux processes are created by fork() and exec(). The very first process of POSIX systems is init and subsequent processes are derived from the init as parent. These subsequent processes are child processes. During forking the parent process copies itself - with all I/O, address space, stack, everything. The only thing that is different is the process ID. The parent and child will have 2 different process IDs. The system() library function uses fork(2) to create a child process that executes the shell command specified in command using execl(3) as follows: execl("/bin/sh", "sh", "-c", command, (char *) 0); system() returns after the command has been completed. system() executes a command specified in command by calling /bin/sh -c command , and returns after the command has been completed. During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.  system() calls are often made within programs to execut

Vaadin vs GWT

From Chapter 1 of book of Vaadin I quote the following. Vaadin Framework is a Java web application development framework that is designed to make creation and maintenance of high quality web-based user interfaces easy. Vaadin supports two different programming models: server-side and client-side . The server-driven programming model is the more powerful one . It lets you forget the web and program user interfaces much like you would program a desktop application with conventional Java toolkits such as AWT, Swing, or SWT. But easier. While traditional web programming is a fun way to spend your time learning new web technologies, you probably want to be productive and concentrate on the application logic. The server-side Vaadin framework takes care of managing the user interface in the browser and the AJAX communications between the browser and the server . With the Vaadin approach, you do not need to learn and deal directly with browser technologies, such as HTML or JavaScript.

C++ Callbacks using function pointers vs boost bind +boost function

In C, the most common uses of callbacks are as parameters to library functions like qsort , and as callbacks for Windows functions, etc. For example you might have a library that provides some sorting functions but you want to allow the library user to provide his own sorting function. Since the arguments and the return values do not change depending on the sorting algorithm, this can be facilitated in a convenient manner using function callbacks. Callbacks are also used as event listeners. onMouseClick(), onTerminalInput(), onData(), onConnectionStatus(), onRead() are probably some examples you've already seen in different libraries. The libraries have these callback functions and the users of the library are supposed to implement them. The library has a function pointer to these functions and calls them on their event loop which will invoke the code of the inherited classes of the library user. The implementation of function pointers is simple: they are just "code p