Feeds:
Posts

## Posts Tagged ‘Compilation’

Just by playing around with CADABRA, I found out the existence of a super-useful LaTeX package, called breqn, which allows to break long equations at the edge of the page… like the wraping feature of most text editors.

However, when one manipulates really long expressions, I’d like to break these long equations through the page. I’m still looking for this feature… in that case I can improve even more the behaviour of cadabra‘s notebook, when compiling it to LaTeX.

Any suggestions???

Cheers!

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" by << "\\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 ## Footnotes: 1This is located a few lines below the lines where the LaTeX preamble is defined Created: 2014-02-18 Tue 10:09 Emacs 24.3.1 (Org mode 8.2.5h) Validate Read Full Post » ## Installing SAGE from the source on Debian. I’m installing SAGE1 v.5.12 on my laptop which runs Debian. Here I describe the procedure. 1. Since there is no Debian binary package, you should download the source code. Here the link. 2. When it finishes, open a terminal C-M-t (sorry for the emacs notation, it means Ctrl+Alt+t) • Go to the Downloads folder (or the right place where the tar file was saved) $ cd ~/Downloads
• Untar the file
$tar xvf sage-5.12.tar • Move to the sage-5.12 folder just created cd sage-5.12/ 3. Install the dependencies of the first line. Optionally install LaTeX and ImageMagick using the second line. (NOTE: superuser power is needed to run the below code) $ sudo apt-get install -y gcc perl m4 dpkg-dev
$sudo apt-get install -y texlive imagemagick 4. In machines with more than one core, the instruction to perform parallel compilation is (yo should change the “4” by the amount of cores in your machine) $ export MAKE="make -j4"
5. Now is time to compile the code.For a local compilation, run
make

For a
You can relax, go and have a coffee, because the compilation may longs one hour (or more depending of the machine specifications).

6. For running the software after the installation is complete, run (on the SAGE directory) the command
$./sage • I don’t like to move to the SAGE directory every time and then run the ./sage command, therefore, I tend to create an alias on my ~/.bash_aliases file, $ echo "alias sage="sh ~/Downloads/sage-5.12/sage" >> ~/.bash_aliases

This command adds the line alias sage="sh ~/Downloads/sage-5.12/sage at the end of the file ~/.bash_aliases, you can do it by hand with your favourite editor (gedit, emacs, nano, vim, …)

• If you refresh your terminal (or open a new one) you just have to run the command sage to start SAGE. Additionally, the notebook environment can be started directly from the terminal by using the flag -n,
$sage -n Hope you find this post useful! Remember to leave your comments or suggestions. Enjoy! ## Footnotes: 1SAGE is an open source mathematical software which allows numerical and symbolic manipulations Read Full Post » ## Installing CalcHEP on Ubuntu In order to install CalcHEP, one needs to download the code and to compile it. The code can be found at http://theory.sinp.msu.ru/~pukhov/calchep.html, as usual it is recommended to download the current version, unless a major pre-requisite problem is in sight. It is useful to install some packages before start compiling CalcHEP $ sudo apt-get install cernlib gfortran xlibx11-dev

Then, go to the folder where CalcHEP was downloaded and decompress it,

 $tar -xzf calchep_3.4.cpc.tgz Now, move to the calchep_3.4.cpc folder and compile the code $ cd calchep.3.4.cpc
$make If the code has compiled without errors, it is enough to start working. However, usually it is recommended to do a couple of extra things. ## Creating a Working folder The default work directory is $CALCHEP/work/

, but in general it is a good idea to have an independent “work folder”, in order for doing so, in the CalcHEP directory there is a script to create that folder… it is called mkUsrDir and admits one argument (the path to the folder you want to create)

 $./mkUsrDir ~/Documents/WorkCalcHEP Once created the working directory, you can move there and call the CalcHEP console (assuming the directory created above I would do the following) $ cd ~/Documents/WorkCalcHEP
$./calchep and you get this: Now, you are ready to start working! Read Full Post » ## LaTeX Tip: Dynkin Diagrams using Tikz Hi everyone, I’ve include the code for drawing Dynkin diagrams using Tikz package in LaTeX \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,0) node[anchor=east] {$A_n$}; \foreach \x in {0,...,5} \draw[xshift=\x cm,thick] (\x cm,0) circle (.3cm); \draw[dotted,thick] (0.3 cm,0) -- +(1.4 cm,0); \foreach \y in {1.15,...,4.15} \draw[xshift=\y cm,thick] (\y cm,0) -- +(1.4 cm,0); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,0) node[anchor=east] {$B_n$}; \foreach \x in {0,...,4} \draw[xshift=\x cm,thick] (\x cm,0) circle (.3cm); \draw[xshift=5 cm,thick,fill=black] (5 cm, 0) circle (.3 cm); \draw[dotted,thick] (0.3 cm,0) -- +(1.4 cm,0); \foreach \y in {1.15,...,3.15} \draw[xshift=\y cm,thick] (\y cm,0) -- +(1.4 cm,0); \draw[thick] (8.3 cm, .1 cm) -- +(1.4 cm,0); \draw[thick] (8.3 cm, -.1 cm) -- +(1.4 cm,0); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,0) node[anchor=east] {$C_n$}; \foreach \x in {0,...,4} \draw[xshift=\x cm,thick,fill=black] (\x cm,0) circle (.3cm); \draw[xshift=5 cm,thick] (5 cm, 0) circle (.3 cm); \draw[dotted,thick] (0.3 cm,0) -- +(1.4 cm,0); \foreach \y in {1.15,...,3.15} \draw[xshift=\y cm,thick] (\y cm,0) -- +(1.4 cm,0); \draw[thick] (8.3 cm, .1 cm) -- +(1.4 cm,0); \draw[thick] (8.3 cm, -.1 cm) -- +(1.4 cm,0); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,0) node[anchor=east] {$D_n$}; \foreach \x in {0,...,4} \draw[xshift=\x cm,thick] (\x cm,0) circle (.3cm); \draw[xshift=8 cm,thick] (30: 17 mm) circle (.3cm); \draw[xshift=8 cm,thick] (-30: 17 mm) circle (.3cm); \draw[dotted,thick] (0.3 cm,0) -- +(1.4 cm,0); \foreach \y in {1.15,...,3.15} \draw[xshift=\y cm,thick] (\y cm,0) -- +(1.4 cm,0); \draw[xshift=8 cm,thick] (30: 3 mm) -- (30: 14 mm); \draw[xshift=8 cm,thick] (-30: 3 mm) -- (-30: 14 mm); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,0) node[anchor=east] {$G_2$}; \draw[thick] (0 ,0) circle (.3 cm); \draw[thick,fill=black] (2 cm,0) circle (.3 cm); \draw[thick] (30: 3mm) -- +(1.5 cm, 0); \draw[thick] (0: 3 mm) -- +(1.4 cm, 0); \draw[thick] (-30: 3 mm) -- +(1.5 cm, 0); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-3,0) node[anchor=east] {$F_4$}; \draw[thick] (-2 cm ,0) circle (.3 cm); \draw[thick] (0 ,0) circle (.3 cm); \draw[thick,fill=black] (2 cm,0) circle (.3 cm); \draw[thick,fill=black] (4 cm,0) circle (.3 cm); \draw[thick] (15: 3mm) -- +(1.5 cm, 0); \draw[xshift=-2 cm,thick] (0: 3 mm) -- +(1.4 cm, 0); \draw[thick] (-15: 3 mm) -- +(1.5 cm, 0); \draw[xshift=2 cm,thick] (0: 3 mm) -- +(1.4 cm, 0); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,1) node[anchor=east] {$E_6$}; \foreach \x in {0,...,4} \draw[thick,xshift=\x cm] (\x cm,0) circle (3 mm); \foreach \y in {0,...,3} \draw[thick,xshift=\y cm] (\y cm,0) ++(.3 cm, 0) -- +(14 mm,0); \draw[thick] (4 cm,2 cm) circle (3 mm); \draw[thick] (4 cm, 3mm) -- +(0, 1.4 cm); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,1) node[anchor=east] {$E_7$}; \foreach \x in {0,...,5} \draw[thick,xshift=\x cm] (\x cm,0) circle (3 mm); \foreach \y in {0,...,4} \draw[thick,xshift=\y cm] (\y cm,0) ++(.3 cm, 0) -- +(14 mm,0); \draw[thick] (4 cm,2 cm) circle (3 mm); \draw[thick] (4 cm, 3mm) -- +(0, 1.4 cm); \end{tikzpicture} \end{center} \begin{center} \begin{tikzpicture}[scale=.4] \draw (-1,1) node[anchor=east] {$E_8$}; \foreach \x in {0,...,6} \draw[thick,xshift=\x cm] (\x cm,0) circle (3 mm); \foreach \y in {0,...,5} \draw[thick,xshift=\y cm] (\y cm,0) ++(.3 cm, 0) -- +(14 mm,0); \draw[thick] (4 cm,2 cm) circle (3 mm); \draw[thick] (4 cm, 3mm) -- +(0, 1.4 cm); \end{tikzpicture} \end{center} Bye DOX Read Full Post » ## Document edition with LaTeX I define myself as a $\LaTeX$ lover. I write all my documents using $\LaTeX$. In this post I’d like to review some features about $\LaTeX$ writing and compilation. Since I’m a Linux user, and don’t have any idea on how does windows work, I’ll restrict myself to Linux OS… particularly Debian based ones, such as, Ubuntu, Mint, and so on. ## Installing the Compiler The easiest way of installing the $\LaTeX$ compiler in Debian based Linux, is through the Terminal, (you should have sudoes power) $ sudo apt-get install texlive

or if you prefer to install all the possible packages,

## First LaTeX Document

From now on, I’d restrict to Emacs editor (which is my favourite), the terminal for compiling the document, and evince as viewer.

NOTE: In case you choose to try emacs yourself, I recommend to check some old post of mine, about an emacs error, about environments, or emacs and LaTeX.

### Three first lines

All $\LaTeX$ document has the three very first lines which define it.

\documentclass{report} \begin{document} \end{document}

The first one define the type of document one’d like to write, some classes are

• report: a book-like document, probably less complex
• book: specially for writing books
• article: for scientific articles
• letter: for writing letters
• beamer: for presentations (see for example this post)
• currvita: for writing curricula vitae
• and many more…

All that is written between the begin and end document is called the body of the document, in there all chapters, sections and so on is included.

A special part of the document is the area between the documentclass and the begin document. This is called preamble, and there all the special request about our document are specified.

### Giving some Format

In order to start giving structure to our document, we need to know the kind of structures defined in $\LaTeX$,

• part: for book and report classes
• chapter: for book and report classes
• section: for book, report and article classes
• subsection: as above
• subsubsection: as above
• paragraph: as above
• subparagraph: as above

by now, we restrict ourself to these three classes, because the other are quite different.

Each structure is understand as a command, thus it must be presided by the backslash and include into the body of the document,

\documentclass{report}

\begin{document}

\chapter{Introduction}

\end{document}

As you might notice, the name of the chapter is enclosed by curly brackets.

NOTE 1: From part to subsubsection, structures are numbered by default. If you’d like to avoid the number, use an asterisk as shown below,

\documentclass{report}

\begin{document}

\chapter*{Introduction}

\end{document}

NOTE 2: A huge difference between a chapter (which I’m calling structure) and environment (such as document), is that the former ends when a new structure is given, while the later has a beginning and an end.

#### Some Environments

There are lots of different environments that might be used while writing a document, such as,

• equation: for writing a single numbered equation. Use equation* for unnumbered ones.
• eqnarray: for writing multiple numbered aligned equations. Use \nonumber for avoid a numbered line, \\ split the line, and && for telling where to align(the sign could be surrounding a sign).
• quote: for quotations.
• itemize: for unnumbered list.
• enumerate: for numbered list.
• figure: for adding numbered and possibly captioned figures.
• table: for adding numbered and possibly captioned tables.
• tabular: for constructing tables.
• minipage: allows to construct a mini-paga on the document, like a post it!
• and a long standing list which cannot be possible cover in a post!

### Compiling the Document

Since $\LaTeX$ is a programming language, one necessarily has to compile the document to get a PDF or PS (human) readable file.

The very fist step is to save the plain text file, the extension must be .tex, as it’s customary, I’ll call our foo.tex. Since compilation usually generates a lot of trash files, the best place to saave the plain text is in a folder dedicated for latex files.

In Emacs the keys

Ctrl-x Ctrl-s

abbreviated by  C-x C-s, saves the file… or buffer in Emacs jargon. The first time you save the file, a name must be given, ex.,  ~/Latex/foo.tex.

NOTE: I assume that a folder Latex was created in your home folder (~).

Once saved, go to the terminal and change the promt to the Latex folder,

 $cd ~/Latex and compile the file with pdflatex command $ pdflatex foo.tex

Finally open the document, with evince,

 $evince foo.pdf & 😀 Yeah babe!!!! That’s right… your first document written in $\LaTeX$. ### Writing Equations I’m a physicist, so I’m used to write lots of equations. I’ll explain some examples, $$\vec{F} = m \vec{a}$$ results in $\vec{F} = m \vec{a}$ or the famous Einstein’s relation, $$E = m c^2$$ results in $E = m c^2.$ More complicated examples, $$\frac{\partial^2 }{\partial t^2}x(t) + \omega^2 x(t) = 0\;\Rightarrow\; x(t) = A\sin(\omega t)+ B\cos(\omega t)$$ results in $\frac{\partial^2 }{\partial t^2}x(t) + \omega^2 x(t) = 0\;\Rightarrow\; x(t) = A\sin(\omega t)+ B\cos(\omega t)$ With this example we opened the gate of Greek alphabet in mathematical mode, and Calculus notation… nevertheless, there exist endless possibilities. I encourage you to check symbols-a4. The best of the compiled text, is that numbers (of section, chapter, equations, tables, or figures) are assigned by the compiler… therefore, you don’t need to remember those damn numbers. So, How do I refer to an equation? First, give a name to the equation, with the label command $$E = m c^2 \label{emc2}$$ and then, call it with the ref command, As we saw before, the mass relation (\ref{emc2}), bla bla bla... After the compilation the precise number appears. NOTE: The same principle work for any other structure of the document or numbered environment. ### And the Title Page? As you have notice, there’s a huge difference between WYSIWYG editors (Office-like) and WYWIWYG ones (which must be compiled). The maketitle command orders to the compiler to create a title page. The data should be included in the preamble, whilst the command form part of the document body, \documentclass{report} \title{My first document in \LaTeX{}} \author{Dox Drum} \date{\today} \begin{document} \maketitle \chapter*{Introduction} The harmonic oscillator is driven by the differential equation, $$\frac{\partial^2 }{\partial t^2}x(t) + \omega^2 x(t) = 0\;\Rightarrow\; x(t) = A\sin(\omega t)+ B\cos(\omega t).$$ \end{document} ### Listing As we saw above, list are made with the commands itemize or enumerate, whether you want it to be numbered or not. Ex.: \begin{itemize} \item This got no number \item Neither does it! \begin{enumerate} \item This is number one \item number two \end{enumerate} \item Another with no number \end{itemize} which is a numbered list inside a unnumbered one. Download the PDF document! Read Full Post » ## Installing and Using SageTeX. 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. ## Pre-requisites. 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

and that’s it.

## Configuration.

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 \ /usr/share/texmf/tex/latex$ 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

\usepackage{sagetex}

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!