Posts Tagged ‘Compile’

Goal: a cadabra notebook more LaTeX friendly.

  1. I run a Debian system. Don’t know why, but the original source code in the git repo didn’t work!!!What did I do? I downloaded the code from the Debian repository.
    $ sudo apt-get build-dep cadabra # Install all dependences
    $ mkdir -p ~/Software # Create a folder to download the source
    $ cd ~/Software # Move to the folder
    $ apt-get source cadabra # Download the source code (from Debian)
  2. On the cadabra folder created through the last command line, I looked for the window.cc file and open it
    $ emacs cadabra-1.29/gui/window.cc &
  3. On the window.cc file I changed:
    • The LaTeX package color by the improved xcolor, by changing the string
      << "\\usepackage[usenames]{color}\n"


      << "\\usepackage{xcolor}\n"
    • I added the LaTeX package listings, which improves the verbatim properties (among other things). Right after the mentioned xcolor line, I added the following
      << "\\usepackage{listings}\n"
      << "\\lstset{\n"
      << "  basicstyle=\\small\\color{blue}\\ttfamily,\n"
      << "  breaklines=true,\n"
      << "  columns=fullflexible,\n"
      << "  commentstyle=\\color{gray!60},\n"
      << "  morecomment=[l]{\\%\\%},\n}"

      This allows the Cadabra code to break at the end of the line instead of going out of the page, when compiled to LaTeX (similar to what breqn does on equations).

    • Now, I changed on the DataCell::c_input: case,1 the strings {\\color[named]{Blue}\\begin{verbatim}\n by \\begin{lstlisting}\n, and \n\\end{verbatim}}\n by \n\\end{lstlisting}\n.Far below, the lines with the code if(ln=="{\\color[named]{Blue}\\begin{verbatim}") { should be changed to if(ln=="\\begin{lstlisting}") {, as well as else if(ln=="\\end{verbatim}}") { should be changed to else if(ln=="\\end{lstlisting}") {.
    • Save all the changes
  4. Finally, time to compile
    $ ./configure
    $ make
    $ sudo make install
  5. If your compilation/installation went through, and you try to open an old cadabra notebook (a notebook created with the original cadabra code), the program will complain that the file is not compatible… but I created a small script to transform the old files into new files! Download it here!!USAGE:
    $ ./transf_cadabra oldfile.cnb newfile.cnb


1This is located a few lines below the lines where the LaTeX preamble is defined

Author: Oscar Castillo-Felisola

Created: 2014-02-18 Tue 10:09

Emacs 24.3.1 (Org mode 8.2.5h)


Read Full Post »

A few minuted ago I could install and use the sagetex package for Sage(math). I’d like to thank ElMonkey for helping me via the IRC channel #sage-devel.


It is assumed that you have installed

  • A LaTeX compiler,
  • A LaTeX editor,
  • and Sage(math)

all of them configured and working properly.

Downloading the Package.

Get the last version of the package in http://www.sagemath.org/packages/optional/.

Installing the Package.

Useful Advise.

My Sage script is located in a sub/sub/sub/subfolder/Sage-4.3.1 (from my HOME folder), so when I want to running it, I should type

$ sub/sub/sub/subfolder/Sage-4.3.1/./sage

It isn’t nice to repeat this one and again, every day.

Thus, I created an alias.

Open the .bashrc file in your editor (gedit for example)

$ gedit .bashrc

add (at the end of the file) the line

alias sage='/path/to/your/sage/folder/./sage'

which in my example would be,

alias sage='/home/doxdrum/sub/sub/sub/subfolder/Sage-4.3.1/./sage'

Save and close the editor. Now in the terminal,

$ source .bashrc

and from now on I just type

$ sage

for running the program.

The real installation.

Now, type in the terminal

$ sage -i sagetex-2.2.1.spkg

and that’s it.


After the installation, a new folder is placed into the Sage folder. Look into local/share/texmf. All files (and folders) inside it must be copied to the LaTeX tree.

In a Linux distribution the LaTeX tree should be placed in /usr/share/texmf/tex/latex

$ sudo cp -r /path/to/Sage-4.3.1/local/share/texmf \
$ sudo mktexlsr /usr/share/texmf/tex/latex

This should work. However, if it doesn’t… the desperate method is to copy the sagetex.sty from /path/to/Sage-4.3.1/local/share/texmf to the folder of the TEX file.

The TeX File.

It is time to create a file.tex, just as any other TEX file. Add the line


to the preable.

Compiling the TeX file.

When you run

$ pdflatex file.tex

the compilator exits with errors… but you get a file.sage, sage-compile it and run pdflatex again,

$ sage file.sage
$ pdflatex file.tex

There it is!!!

A resume compilation line could be

$ pdflatex file.tex && sage file.sage && pdflatex file.tex

Enjoy it!

Read Full Post »