Goal: a cadabra notebook more LaTeX friendly.
- 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)
- On the
cadabra
folder created through the last command line, I looked for thewindow.cc
file and open it$ emacs cadabra-1.29/gui/window.cc &
- On the
window.cc
file I changed:- The LaTeX package
color
by the improvedxcolor
, by changing the string<< "\\usepackage[usenames]{color}\n"
by
<< "\\usepackage{xcolor}\n"
- I added the LaTeX package
listings
, which improves the verbatim properties (among other things). Right after the mentionedxcolor
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 whatbreqn
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 codeif(ln=="{\\color[named]{Blue}\\begin{verbatim}") {
should be changed toif(ln=="\\begin{lstlisting}") {
, as well aselse if(ln=="\\end{verbatim}}") {
should be changed toelse if(ln=="\\end{lstlisting}") {
. - Save all the changes
- The LaTeX package
- Finally, time to compile
$ ./configure $ make $ sudo make install
- 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
Footnotes:
1This is located a few lines below the lines where the LaTeX preamble is defined
[…] a previous post I described how to change the LaTeX options of the Cadabra […]
I followed the modifications you suggest to Cadabra and everything worked smoothly! thanks, now i can compile cadabra notebooks in latex with no errors! Well, except for the dmath environment in latex, that does not break equations from page to page whenever they are too long to fit one single page, but i guess that’s a a different issue…
THANKS!