Quote of the day
Posted by: nico on
May 30th, 2009 |
Filed under: Programming
If you can’t see any error messages it must be because you didn’t start it. Or it has already core-dumped.
Posted by: nico on
May 30th, 2009 |
Filed under: Programming
If you can’t see any error messages it must be because you didn’t start it. Or it has already core-dumped.
Posted by: nico on
May 28th, 2009 |
Filed under: LaTeX
LaTeX basicsRemember last post? I mentioned its possible to create several type of documents. Even if the structure will, most likely, be different for different applications, there’s a common ground which can be used for most LaTeX documents. I’d go as far as saying ALL of them, but in LaTeX it’s possible to override everything and anything. Any reasonable package won’t do it, so let’s see some LaTeX basics you can use for any project. |
![]() |
The first thing to understand about LaTeX, it’s not WYSIWYG. If you use a plain text editor you won’t see any kind of format at all (LyX provides some sort of preview though). This confuses some people who, used to Word-like applications, tend to think in the structure and desing before the contents; LaTeX is different in the way to structure documents, a way which is called What You See Is What You Mean, WYSIWYM, for short.
What does being WYSIWYM means? You just think about the content and structure and it gets formatted for you. Instead of saying you want “Centered, Arial 12px orange font with pink background” just say “this is a title”. The format will be there, but not attached to the content – it’ll be in a “stylesheet”, the document’s class (*). Of course, these styles can be changed too
WYSIWYM has a downside too: you’ll have to “compile” the mark-up text into a pdf (or any other format) using pdflatex, for example. It may be a shock to some but it’s not difficult, just write “pdf2latex file.tex” and let it work its magic. You can use the makefile I’m attaching to this post too, if you feel comfortable with makefiles (The makefile has a few cool tricks you can use too. I’ll explain all of it in another entry).
In GNU/Linux you can find lots of examples and templates in /usr/share/doc/texlive-doc/latex/ (no idea where may they be in Windows). Writing this article I found out lots of templates I didn’t know about so go and take a look. Go on, I’ll wait here. Done? Ok, let’s move on.
In LaTeX there’s a basic structure every document follows:
What comes before the \begin‘ning is the preamble. There you can tell LaTeX:
This post is getting a little bit too large so I’ll leave some basic commands for the next one; you should be able to start writing some basic documents anyway.
(*) <Rant mode> Yeah, something like content and style separation but only a couple of decades before it was “invented” for the WWW.</Rant mode>
![]() |
So, you have a paragraph, or any kind of text, and need to replace a substring without altering other paragraphs. You could write :set number and then :A,Bs/what to search/what to replace/g, being A and B the start and end of the paragraph, or you could just use visual mode. |
Enter line selection mode (Shift + V) and then select a block of text. Without moving the cursor any further type :s/SEARCH/REPLACE and the search string in the selected block will be replaced without altering any other part of the document.
Posted by: nico on
May 23rd, 2009 |
Filed under: Uncategorized
Posted by: nico on
May 21st, 2009 |
Filed under: LaTeX
As previously stated, programmers will be more comfortable around plain LaTeX but that’s not the only pre requisite – you should be somewhat familiar with the console in Linux (no idea about LaTeX on Windows) and have some patience to read a couple of manuals. Once you have mastered the basics it’s much easier, so don’t get discouraged.
If you feel you don’t fit the profile perhaps LyX is a better alternative than plain LaTeX; it’s very easy to use and quite user friendly. It won’t be that great for presentations and other, more “advanced”, documents though.
That’s an easy one, check My Articles section for some examples. You can create any kind of document but it’s better suited for those in which you care most about the content and don’t want to get bogged down with perky design details.
Last (for this entry) but not least, what editor can you use to create LaTeX documents? Well, LaTeX is basically plain text so any editor will do. There are some LaTeX-specific editors, I like ViM myself. There’ll be a complete post dedicated to LaTeX + Vim, coming soon.
This article will be the first in a series of LaTeX survival guide so stay tuned.
Posted by: nico on
May 19th, 2009 |
Filed under: Linux, Programming
| Check the other two parts of this series: | ![]() |
I recently updated to Ubuntu 9.04 and had to reinstall my work computer. Since the stuff I use for work (mostly c++ programming) was left out in the previous two posts I’ll post it here:
Done, a couple of apt-get’s and you are ready to build your c++ projects! (Ok, actually only the first one is needed, the others are nice-to-have programs).
Posted by: nico on
May 14th, 2009 |
Filed under: Linux, Programming
I present to you the latest release from Wheel Reinventions Inc. – Already Invented dept. – a script to check the remaining battery time from Linux console.
Yes, I was bored, so? I’m planning to release a new bogosort implementation after this one, what do you think?
Jokes aside, this nifty script shows how flexible can be the model “everything is a file” which Unix-y systems implement. With a couple of pipes (and an almost magical incantation for those uninitiated in the console cult) you can do lots of stuff with very little work
This concept could be associated with the way polymorfism works in a programming language, but that’s an entry for another day.
Posted by: nico on
May 12th, 2009 |
Filed under: LaTeX
![]() |
Some time ago I wrote a review about LyX for DPOTD (recommended link) and now I think it’s time for an update: what can you do when LyX is not enough? |
I’ll quote myself; the original article ends (almost) like this:
What LyX isn’t for
Although LyX may be a valuable piece in anyone toolkit it’s worth noticing it isn’t exactly the Swiss army knife of the text editors. If you need to define a very customized layout or format, like slides for a presentation, this is the wrong tool for the job.
After having prepared several presentations with LyX (even my CV!) I’d like to write some more on this last part. Even if I thought that my original comment was mistaken I write once again the same: when you have to create a presentation LyX is not the tool for the job, LaTeX is.
As I explained in that article, LyX is a front-end for LaTeX but at the same time it’s only a small part of LaTeX. Doing several presentations in LyX (using Beamer, a package I’ll talk about in another post) I noticed that most of my documents where “ERT”, evil red text, which is nothing else than plain TeX code: that means, each time more, I was using LaTeX functionality not available from LyX. This is the reason I’ve decided to write a how-to LaTeX, a small survival guide for those want to start using with the tips and tricks I’ve learned in this time.
The target for these posts series will be, mainly, programmers or other advanced users, without fear of working a little bit in the console, markup languages and maybe a makefile.
Soon the first part
![]() |
There’s normal mode, command mode and a third, less known to the begginers, visual mode. What’s this mode about? |
Using Vim on visual mode can make some rather complex tasks and regex operations go away with a couple of keystrokes and it’s as easy as selecting the text you want with the cursor.
Move your cursor over the first part of the text you’re trying to select and press Ctrl + V to set Vim to visual mode, then move the cursor to the last part of the text you’re trying to select (it works in blocks, not character by character nor line by line… try it, it’s easier than it may seem).
What can you do after selecting text this way? Pretty much anything else you’d do with normal text, like cut (x) and paste (p). This is specially useful when working with formated text (i.e. programming).
Visual mode can also work with lines (use Shift + V insted. Notice the uppercase V) and with other modes; check the manual for more information.