Doing arithmetic in TeX

I have just discovered accidentally how to perform simple arithmetic operations in TeX:

\number\numexpr 5+5\relax

And this will print the result, not the operands.

Posted in Personal technotes, TeX. Comments Off

\include and \input

Thanks to this comment, I have realized the main difference between \include and \input in LaTeX: \include has a page break before and after the file and \input doesn’t.

Posted in Personal technotes, TeX. Comments Off

Magnifying with XeTeX

When magnifying with XeTeX using the geometry package is important not to forget that the documentclass should not have the page size set on it, instead of having it set on the proper geometry option.

Posted in Personal technotes, TeX. Comments Off

When openSUSE seems not be able to handle a DHCP connection

For some strange reason, my openSUSE 11.1 distribution seems not to be able to negotiate a DHCP Ethernet connection at home. Ubuntu 9.04 and Fedora 11 (live versions) are able to do that using the same computer and connections.

The only way it seemed to work was typing dhcpcd -k eth0 and after that dhcpcd -n eth0 (both as root). I don’t know what does it actually change, since I must keep that window open and the system considers that it isn’t connected.

It might be a bug, but sorry, too tricky to be reported.

Posted in Personal technotes, openSUSE. Comments Off

How to generate a booklet from a PDF file

Using ConTeXt (taken from the imposition explanation):

\definepapersize	[filius][width=136mm, height=232mm]
\setuppapersize		[filius][A4,landscape]
\setuparranging		[2UP,doublesided]
\setuplayout [backspace=0pt,
    topspace=0pt,
       width=middle,
      height=middle,
    location=middle,
      header=0pt,
      footer=0pt,
      grid=no, marking=off]
\starttext
\insertpages
  [document.pdf][width=0pt]
\stoptext

You have to replace the document.pdf with the real file name and filius with the original paper size.

Posted in Personal technotes, TeX. Comments Off

Searching for text in directories

To find which pure text files contains a given text from the command line, this is the proper command:

grep -ilr "pattern" directory

The -i option makes the search case-insensitive, -r searches the pattern recursively (that is, in the subdirectories that the actual directory might contain), and -l shows the file list where the pattern occurs.

Thanks to Juan Luis Belmonte for the tip (credit where credit is due).

Posted in Personal technotes. Comments Off

Backing up all user data in Linux

One of the most I like most in Linux is the strong separation among user data and system data. This makes installing new versions, or moving data from different hard disks (and other sensitive operations that require all your data).

To copy all user data you need to type:

tar -cvpf compressed-file.tar /home/

This creates (-c) a file (-f) named compressed-file.tar retaining file and folder permissions and storing there all data from the /home/ directory.

To extract this you would only need to type:

tar -xf compressed-file.tar

The -x option specifies the extraction from -f (file).

To restore the data, the operation should be done at the root directory (since files will be extracted with full-path directories).

Posted in Personal technotes. Comments Off

Connecting two computers using a twisted pair cable (or a switch)

Sometimes being able to connect two computers using a twisted pair cable or a switch is extremely useful for copying data.

Once we have plugged the cable in both computers (or we have plugged both cables in the switch), we must assign a new IP address to both machines:

ifconfig eth0 10.0.0.1 netmask 255.255.255.0
ifconfig eth0 10.0.0.2 netmask 255.255.255.0

To check whether both computers communicate, we must ping each computer from the other one:

ping 10.0.0.1
ping 10.0.0.2

It is important to ping always the other machine, because pinging the same address (i.e., 10.0.0.1 from 10.0.0.1) always works.

If no packet has been lost, computers communicate because both can send a receive packets. But to move files, one must select a proper protocol.

For security reasons, during this connection no computer should be physically connected to the net.

When everything is done, we get the default internet connection configuration again by restarting the system or by running as administrator:

/etc/init.d/network restart
Posted in Personal technotes. Comments Off

Copying your MBR

To check whether an issue with my laptop’s in-line recording is a hardware problem or a buggy audio driver, the guy from Dell’s technical support asked me to install Windows to discard a software failure. I have been asked to do that after having the mainboard replaced (laptops have no separated sound cards). I have to decrease the size of one of my partitions, create a new one and format it as FAT32.

But the issue here is that Windows will rewrite the master boot record (to promote competition ;-) ) when installing it.

I have asked how to restore the original MBR at Mandriva Expert and thanks to the replies, I have a method to copy and restore the MBR.

As administrator, run the following command:

dd if=/dev/sda of=mbrsave bs=512 count=1

To have it back, run as administrator again:

dd if=/path/to/mbrsave of=/dev/sda

Many thanks, George and Jean-Pierre, for the tip.

Posted in Personal technotes. Comments Off

On presentation technologies (what Lessig might need)

Reading Lawrence Lessig’s Experiments in presentation technology, I became extremely interested on his efforts when I read:

My hope is to put every presentation I’ve made, with audio and the source files, up for anyone to do with as they wish. That turns out to be harder than it should be. Any advice or help would be greatly appreciated.

It sounds promising, but there is an issue that makes the task harder than it seems:

The only difficult part about this was listening to myself again (and again) as I built this.

If I don’t understand the issue here wrong, the problem is the timeline to sync audio and each slide. It is difficult to guess how long each slide should take. And if you have many slides, this task will be tedious. And a solution for this would be that the computer counts for you.

Computers are mainly counting machines. It should not be difficult to implement a multiplatform program (using wxWidgets or something similar) that is able to detect keystrokes defined by the user to start the timeline, detect each new slide transition and finish the timeline and that is also able to export this timeline into a text file.

An example of this would be a (Keynote/PowerPoint/Impress/PDF) presentation not using the fullscreen mode to see what comes next (or in a mode that enables you to see previous and next slides). You start recording the audio and start the timeline. Each slide transition is detected by the program, so the syncing will be perfect. You finish the timeline and stop recording. The ouput file would be:

00:00:05
00:00:10
00:00:12
00:00:18.25
00:00:23

(Of course, the program could have another features, but this is only a basic sketch.)

If I’m not wrong, Lawrence Lessig could even generate the timeline when giving the presentation. This would be the first step to generate the presentation with audio in a PDF file (as suggested here).