# LaTex. Cool but too much hassles

Since I was studying Algorithm, dealing with mathematics and formulas and steps and all, I figured the best way to type those is to use TeX, a markup system invented by Knuth. It was cool. It was hips. (Trust me on this, better than a GUI. ) See this.

However, no silver bullet. Still give me frustration. Maybe that how you learn. Hair scratching.

1. A horse who is hard to tame because I don’t know the trick.

For the long time I believe that you could figure things out if you google long enough and with the right term. My approach to LaTex is this : I would type in the homework ( yes , mainly for homework ) and then added the right syntax ( by googling ) if I want to edit anything. My main goal in the beginning is just : bold some header, newline, indenting, etc, simple stuff. Tex is like html in that regard but it is so much shorter. This is bold \textbf{ words to bold }; newline is \\, etc. But, sometimes { just does not appear because I have escape it like so \{. Hmm, no biggie. I was soon not satisfied with how simple my homework layout work and soon embarked on the long and tedious way of google how to do stuff of which there are like gazillion way of doing. Cannot afford time to do all that.

Bracket everywhere. It just hurt your eyes.

3. Math mode

I said \{ is no biggie. It is a biggie when it comes to math and formula. Why does ^ not render as “raise to the power” or \leq not rendered as “<“, _ as subscript, etc? Instead I have to find alternatives that my system support such as  \textlessthan for freaking “<” not even equal sign; patched it with \textlessthan = . That is monstrously ugly and lengthy….Turns out LaTex has a mathmode that support those. To enter mathmode, I just need to surround the text with \$. Problem solved.

4. Algorithm writing. The real hassles.

I worked it out in paper; just need to reqrite it in LaTex so I could have a better pdf to submit the homework. However this is the big hassle. I was struggling for a whole day. The main reason : indenting. You know how algorithm layout looks like, same block same indentation. Approaching the problem like what I did in 1 would result in a lot of copy and paste which I already did.

And they said DRY. If you could find a way that you could be lazy, by all means, do it.

a. Dependency Hell.

So I sort out to google the solution with right term : “how to write algorithm with latex”. And this link comes up : https://en.wikibooks.org/wiki/LaTeX/Algorithms . There are multiple approaches that I found viable : package{algorithmic} or package{algorithm2e}. Cool. There are good solutions out there. I typed some in and found out that some .sty is not found. Hmm, how is it possible. Thought TexLive-basic is enough. However, it was missing those packages ( I picked it instead of full version is because of its small size — hah, they stripped off packages). Google around for one hour and figured out that my texlive is using tlmgr for package manage. So I fired up the terminal and followed the commands suggested by the website.

I did what I did not want in the first place. Install the whole collection ( package are categorized by collection).

And it worked now. Well, I still have to install package ‘relsize’ to make it work. I guess so they can resize the layout or sth.

b. Convoluted Syntax.

algorthm2e is really complicated. To make a function you gotta do this:

\SetKwFunction{algo}{algo} \SetKwProg{myalg}{Algorithm}{}{}

That was too much. But I sticked with it anyway. Just to figured out in the end that It format the my next line.

I do not want this

Get me back my original unindentation. After googling for another hour I abandon it and try {algorithmic} instead. This one though I’m still struggling with did not auto my whole page format. So I guess I’ll be with this for awhile