Saturday, 20 August 2016

The Lucidity of LaTeX: An Introduction

Users of open source software are often plagued with the problem of text editors. For some reason, despite the marvellous efforts on the part of multiple developers, softwares like LibreOffice and OpenOffice haven't gained the popularity or the feel of a text editor people comfortable use on a daily basis. Many may hold this point in contention (and are welcome to do so in the comments!) but Microsoft Office still commands the world as the most used suite of business software products, despite being a paid application. Familiarity deters the majority from making the change, and certainly companies prefer products tried and tested, and providing official support unlike the help forums of the open source world.

An Bestowal not unlike Prometheus'
The FOSS community has tackled this problem, vanquishing the giant Microsoft almost entirely from the world of academics at least. By appealing to the nerdy, terminal-y and "absolute control" mindsets of coders and academicians alike, they have produced a software intelligent and structured, specifically to attack the problem of standard formatted, BEAUTIFUL documents (on par with Britney Spears wearing it) that the scientific community at large has yearned for.

Introducing LaTeX (LAY-tekh), the emperor of all document preparation systems. The philosophy radiates Jagger's swagger: write, and let the software worry about the formatting. It is designed utopian.

And the tool we shall wield?

For this review, I chose to use the TeXstudio as my editor as it is easily installed from the Ubuntu repository. There also is, among others, Texmaker; but it isn't available on the Ubuntu repos yet. These are available for Windows users too, but the advantage of TeXstudio is it supports a single location installation (like on a flash drive) which will run anywhere.

So why should I use it?

  1.  It automatically formats all the settings of your final output according to your choice of document entered the beginning. Whether article, report or presentations. (aka "beamer" class)
  2. You can easily input mathematical equations and all sorts of symbols within with absolute ease using the intuitive commands for each of them. Even equations and variables as part of the paragraph is supported.
  3. You may have often wrestled with nested indentation, alternating bullet points and numberings, headings, table of contents, figures and maybe even a table of tables. Using LaTeX, this entire process is automated. Since it is essentially code, you have absolute control over every aspect of the output.
  4. Learning the format is a one-time investment (much like Vim). The intuitive nature of the code makes it easier over time to get you more productive, and the use of autocomplete and hotkeys in text editors (like TeXstudio) allows you to blaze through the report at the speed of 218Mbps. Yes, you read that figure right.
  5. Special fonts, code sections, hyperlinks and urls, you name it, they've built. It's waiting for you to just get started.
  6. Arguably, it's so beautiful and aesthetically pleasing it could even get you to want to start writing your project. It has worked for me :D.
The LaTeX effect

The Starter Tips Section

After about a week of uncomfortable use, a familiarity set in. Subsequent experimentation with the hotkeys in TeXstudio absolutely blew my mind. Suddenly, the slow painful thought process of the right choice of section types slowly set in, and it was smooth sailing from here on out. A set of extremely useful hotkeys can be found here, but I'll list out a few of the most used here. In most cases, to apply a property to text, just highlight it and punch in your choice of attribute. Works well especially for bold, italics and inputting mathematical symbols and equations via the "Inline math mode" option.
  • Build & View : F5
  • Italics : Ctrl+I
  • Slanted text: Ctrl+Shift+S
  • Bold : Ctrl+B
  • Inline math mode : Ctrl+Shift+M
  • Numbered equations : Ctrl+Shift+N
  • Subscript : Ctrl+Shift+D
  • Superscript : Ctrl+Shift+U
  • Frac : Alt+Shift+F
  • Left : Ctrl+Shift+L
  • Right : Ctrl+Shift+R
These are pretty much the majority of the hotkeys frequently used, and as can be seen very intuitive and easy to remember. Further autocomplete can be called upon with the standard Ctrl+Space option.

Any Parting Words?

Although the software seems highly skewed towards scientific publishing, it's not too difficult to learn, and therefore can certainly be used by pretty much anyone wishing to produce documents or simple slideshow presentations too. The ease of just beginning right way (pun intended) is evident for short reports and stories, however not having to deal with complications in formatting is especially useful for long books and semester long work logs too.

Friday, 1 January 2016

Guide to the Linux Terminal: Introduction and Basic Navigation

For first time users, the Linux terminal can be quite an intimidating aspect of the operating system. Instead of imagining the terminal as an interface to issue commands to a computer, imagine it to be a chat window which can be used to talk to your computer. The only difference here is, your computer is exactly like your annoying friend who cannot tolerate bad grammar. A terminal will only accept commands (messages) which are framed and constructed correctly. Understanding how it works is a lot simpler than it may seem at first. I will be using a terminal in Linux Mint. But, the concepts remain pretty much the same in all Linux distributions. There may be a few variations which I will cover in another guide.

Location and Paths

The moment you open your terminal you'll see a window which looks something like this.

Now the first line in the terminal says: piyush@piyush-laptop ~ $ 

Here, "piyush" stands for the username of the user which is using the terminal window. Since we are using this terminal from the user account that we've logged in with, this is the username it will show you.

The second part, "@piyush-laptop" stands for the name of the computer you are currently using the terminal in. My laptop's computer name is "piyush-laptop". In your case, it will show you whatever you've set your computer name as.

As far as the "~" is concerned, I will get to that part in a bit when I explain paths. The "$" indicates that you are using a normal terminal window which is sending your commands to Linux using what we call a "Bash shell". If this is too technical for you, all you need to understand is that as long as you see a "$" before your text input cursor, you're using a standard Linux terminal.

The concept of paths is very simple. A path is a unique address which points to any file or directory in your computer. For example, if I wanted the path to a file called resume.pdf which is located inside the Documents folder in my default Linux home directory, the path to the file would read something like this:


Suppose I want the path to a video called webinar.mp4 located in the Videos folder of my Linux home directory, the path will be:


In both the above paths, "/home/piyush/" is the path to the default home directory of the current user logged in to the system. Suppose your username is "john". Then your default home directory would be "/home/john/". To make things simpler, Linux abbreviates the path of the current default home directory to "~". So, my webinar.mp4 file can also be referenced by the path:


Now, coming back to the terminal window where we were discussing the "~" icon; this refers to the present working directory of the terminal. So in case you're asking the computer to perform some operations within a particular directory, you need to make sure that your present working directory path is correct.

Navigation and Basic Commands

The key to using the Linux terminal is not remembering commands, but understanding how commands work. Finding a command is only a Google search away. There are a few commands though, which one ought to know when using a terminal. These are usually used for working your way to your required working directory and then performing whatever operations you wish within the directory.

We spoke about the present working directory in the previous section. When we open a new terminal windows, our present working directory is the default home directory referenced by "~". Suppose we want to change our present working directory, we use the command cd (change directory). Using this command is fairly simple. Suppose we want to move inside the Documents folder present inside the home directory, we will type:

cd Documents/

This will change our present working directory to "~/Documents" 

We can use this command to go literally anywhere in the system. We need not necessarily reference a directory within the current working directory. For example, suppose I wanted to navigate to a folder called Work within my Documents folder from a new terminal window, I can simply type:

cd Documents/Work/

This will change my present working directory to "~/Documents/Work". Note that you can jump to any directory in the system using just the required path after cd. You need not hop from directory to directory to get to where you want.

Very often, we don't know the contents of our present working directory. To find out the contents of the directory, we type ls.

In the above Work directory, there are 3 entries visible immediately after issuing the ls command. Here, "reports.txt" and "database_entries.txt" listed in white are files, whereas "Employees" listed in bold blue is a directory.

This should give you a good sense of where you are within your system and what your working directory contain. If you want to go up a single directory, you can type:

cd ..

This should take you up one directory. You may use this command multiple times to go up multiple directories.

Here are two more pointers to get you started with typing commands like a pro:
  1. Typing a filename/foldername/command partially and then pressing Tab will auto complete it for you. So if you want to type cd Documents, you could simply type cd Doc, and then press Tab. This should auto complete the command for you. Note that auto complete only works if the partial content you have typed is enough to uniquely identify a particular command, folder or file. So if you type cd Do and press Tab, it may refer to the Documents folder or the Downloads folder; hence the terminal won't auto complete the command.
  2. Pressing the Up Arrow key will automatically type in the last command that you entered in the terminal. You can press it multiple times to cycle through all the commands you have previously entered in chronological order. You can also press the Down Arrow to cycle back within the list.
This tutorial should be enough to get you started with basic navigation within the Linux terminal. I'll be covering parameters and file and folder operations in the next tutorial, so stay tuned. Please let me know your feedback in the comments section, and I will try to get back to you as soon as possible.