Posts Tagged ‘Computers’

On a previous post I described how to change the LaTeX options of the Cadabra notebook.

I collaborate with a colleague, who uses the standard cadabra installation. Therefore, If I write a Cadabra notebook, he needs to pullback the personalised notebook to the standard one. The pullback script can be downloaded here!!!

Author: Oscar Castillo-Felisola

Created: 2014-02-18 Tue 20:20

Emacs 24.3.1 (Org mode 8.2.5h)


Read Full Post »

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???


Read Full Post »

The lsusb command lists the USB devices of the computer.


$ lsusb 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 2232:1029  
Bus 002 Device 003: ID 8087:07da Intel Corp. 
Bus 003 Device 002: ID 0458:003a KYE Systems Corp. (Mouse Systems) NetScroll+ Mini Traveler / Genius NetScroll 120

As most commands in Linux, it has some flags, which I’ll explain below. But first, let’s explain a little bit those numbers.

  • Bus: In computer architecture, a bus is a subsystem that transfers data between components inside a computer, or between computers
  • Device: is the specific device number
  • Vendor: The vendor ID is the first (octal) number after the ID label
  • Product: The product ID is the second (octal) number after the ID label, placed after the colon :
  • Description: If available, the final part is a brief description of the product

Options (or flags)

 $ lsusb -v

It is the verbose mode. The detailed information of the devices is shown.

 $ lsusb -t

The devices information is shown as a tree.

 $ lsusb -s 001:

Show the device(s) whose Bus number is 001. In the above output, there are 3 of these.

 $ lsusb -s 001

Show the device(s) whose device number is 001. In the above output, there are 4 of these.

 $ lsusb -s 001:002

Show the device whose Bus and Device number are 001 and 002 respectively.

In the three previous examples the flag s can be changes by d, if one’d like to specify the Vendor and Product ID respectively.



Read Full Post »

WARNING: The following is a PERSONAL brief of part of the second chapter of the book How Linux Works: what every superuser should know by Brian Ward

Linix device files are in the /dev directory. A device can be identified using the ls -l command.

An extract of the output from the command line ls -l /dev is shown below,

crw-rw----+ 1 root cdrom    21,   1 Sep  6 01:23 sg1
lrwxrwxrwx  1 root root           8 Sep  6 01:23 shm -> /run/shm
crw-------  1 root root     10, 231 Sep  6 01:23 snapshot
drwxr-xr-x  3 root root         220 Sep  6 01:23 snd
brw-rw----+ 1 root cdrom    11,   0 Sep  6 01:23 sr0
srw-rw-rw-  1 root root           0 Sep  6 01:23 log
prw-r--r--  1 root root           0 Sep  6 01:23 gpmdata

The first column is a code which indicates the type of ‘file’ (the first character) and permissions (the other nine characters).

If the first character is b, c, p, or s, then the file is a device. These letters stand for block, character, pipe, and socket, respectively:

  • block: Programs access data in a block device in.
  • character: Character devices work with data streams.
  • pipe: are like character devices, but there is another process at the other end of the I/O stream instead of a kernel driver.
  • socket: are special-purpose I/O files offering a type of network interface.

The numbers before the dates in the first two lines of the previous listing are the major and minor device numbers that help the kernel identify the device.


Read Full Post »

Two of the most useful commands for archiving and compressing in Linux are tar and gzip.

gzip stands for GNU zip, which is a similar tool to ZIP (for Windows). Files which end in .gz are GNUzipped. One can decompressed them using the gunzip command.

 $ gunzip file.gz

For compressing a file one uses the gzip command,

 $ gzip file

To create an archive, i.e., to bound a bunch of files, one uses the tar command. However, there are some flags (or options) should be activated:

  • c: creates an archive,
  • f: for given a file name. It is mandatory
  • v: verbose mode, allows to visualise all files of the archive.
  • x: extracts files from an archive.
  • t: table of contents mode. Shows the content of the archive without extracting.


 $ tar cf archive.tar file1 file2 ...

Creates an archive (archive.tar) with files file1, file2, and the others (denoted by the ellipsis).

 $ tar tvf archive.tar

Shows the table of contents of archive.tar.

 $ tar xf archive.tar

Extracts the files of archive.tar in the current directory (pwd).

 $ tar xvf archive.tar

Extract the files of archive.tar in verbose mode. The files ar placed at the pwd.

 $ tar xf archive.tar /your/optional/path

Extracts the files of archive.tar into /your/optional/path.

Archiving and compressing… together

tar and gzip can work together. It’s not rare to find compressed archive, whose extensions are .tar.gz, .tar.lzma, .tar.b2 and so on.

In order to decompress and extract these files one needs to include extra flags (options):

  • z: for uncompressing .gz files.
  • j: for uncompressing .b2 files.
  • --lzma: for uncompressing .lzma files.

More examples

 $ tar xzf archive.tar.gz

Extracts the files of archive.tar.gz in the current directory.

 $ tar xjf archive.tar.b2

Extracts the files of archive.tar.b2 in the current directory.

 $ tar --lzma xf archive.tar.lzma

Extracts the files of archive.tar.lzma in the current directory.


Read Full Post »

When I started to write documents in \LaTeX, I found myself diving into .tex, .out, .aux, .pdf, .jpg files and so on. Thus I developed a system for organizing the files.

(If you are starting with \LaTeX might find useful my previous post here)

The Basic

First, I create a LaTeX folder in my personal Documents directory,

$ mkdir ~/Documents/LaTeX

where all my \LaTeX related files have to be moved.

Since I used to write a lot of reports, articles and letters, the next step is to write a template for each of them (Of course, you could use pre-defined templates, from your LaTeX editor, borrowed from a friend or downloaded from internet).

As an example, I’ve defined

  • base-art.tex
  • base-rep.tex
  • base-PRD.tex: for articles to be send to Physical Review journal.
  • base-book.tex
  • base-beamer.tex
  • base-lett.tex

More Folders

Now, more folder should be created to keep files ordered.

$ cd LaTeX
$ mkdir Docs Pics Finished

Here I’m describing just three, Docs contains the .tex files other than the base-*.tex, Pics contains all figures, and Finished is a place where you can move the PDF files when they are finished.

NOTE: Clearly, you could create folders inside Docs and Pics… say, one for Geography-hw and other for Zen-Martial-arts, and so on.

The base-*.tex File

This is the file which contains the structure of the document, that is:

  • the class
  • the preamble packages, definitions and so on…
  • the begin and end document.

but not the body content… except for the maketitle, tableofcontents, and similars.

So, Where is the content?

The content is written is separated tex files saved in the Docs folder. None of this files have class definitions or, package calls, or begin and end document… they have the written part, example:

%%%  UFO saved as UFO.tex
%%% in the ~/Documents/LaTeX/Docs folder


In the last years, UFO activity has been increased due to 
the lack of faith in the world. 

Do you believe?

\chapter{What is UFO?}
UFO stands for Unidentified Flying Object 

\section{UFO activity}
blah blah blah

and this should be included into the base-rep.tex file, with the input command,





NOTE: When you want to insert a file, which is not in the same folder than the base-*.tex one, the directory to that file must be given.

And the figures?

Now, figures are part of the body, thus they are included in the UFO.tex file, suppose we want to add the figure1.jpg, then our UFO.tex should contain a line like,


NOTE: although UFO.tex is located in Docs folder, the figure file is referred as Pics/figure1.jpg because the compiler starts looking at the “mother” folder, a.k.a., LaTeX.

Compiling the Thing

Of course, for compiling you should type in the terminal,

$ pdflatex base-rep.tex

however, the PDF document will have the same name as their parent tex file, i.e., base-rep.pdf

If you’d like to have a final PDF file with a different name, use instead,

$ pdflatex -jobname UFO base-rep.tex

to get a UFO.pdf file.



Read Full Post »

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,

$ sudo apt-get install texlive-full

NOTE: the full installation needs about 1GB of free pace in your HD, which is not too much by this days, however, downloading the installation packages could long couple of hours with ease.

Choose an Editor

One cannot write a \LaTeX file in a Word Processor as OpenOffice or LibreOffice. Nonetheless, there are different processors which are useful for this end,

  • Gedit: included in most Linux distributions
  • Emacs: a very powerful processor
  • Texmaker: specially designed for LaTeX, in GNOME environment
  • Kile: specially designed for LaTeX, in KDE environment

and many others,

  • Texila
  • Texshop
  • Texmacs
  • et cetera

You could install one or all of them, again using the CLI, for example,

$ sudo apt-get install texmaker emacs gedit-latex-plugin

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.


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,





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,





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,

\title{My first document in \LaTeX{}}
\author{Dox Drum}




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).



As we saw above, list are made with the commands itemize or enumerate, whether you want it to be numbered or not.

\item This got no number
\item Neither does it!
  \item This is number one
  \item number two
\item Another with no number

which is a numbered list inside a unnumbered one.

Download the PDF document!

Read Full Post »

Older Posts »