Beruflich Dokumente
Kultur Dokumente
Now say that ten times in a row, fast, I dare you. Anyhow, we've gathered today to enjoy another ultra-geeky tutorial on how documents ought to be written, styled, formatted, prepared, presented, and in short, written. You may be tempted to use an office suite of some kind and scribble your work in a word processor, but I beg you, don't. There's a whole world of superior alternatives waiting for you, if you're only willing to take the leap of faith and hurl into the chasm of nerdiness. However, office suite fans will tell you that LaTeX is too difficult and that it's only good for scientific documents. Aha! Well, that's kind of true. There are many things you may want in LaTeX, but they are not instantly apparent. In this article, I'd like to show you the common obstacles a recent Word user may face and how to get around them, quickly and painlessly.
Basics
Inserting LaTeX code in LyX documents can be done with Ctrl + L. Permanent changes that affect the entire document can
be inserted in the document preamble, a sort of a template section where you declare your major stuff, like header, footer, bookmarks, colors, etc.
Now, let's examine some popular tricks - or annoyances if you will. I'm trying to tackle the issues that a normal person would bravely encounter when trying to use LaTeX the way they expect the documents to behave.
In no particular order:
You will also need to use the enumitem package; declare in the Preamble:
\ usepackage{ enum t em i }
If this package is not installed, you will need to install it first. You can let your LaTeX software handle the installation or manually download the missing packages and extract them into the right path. Personally, I'd say don't bother. Let the software do all the hard work. For instance, on Windows, MiKTeX will do that for you:
If you want your footnotes to be aligned nicely, here's the code what does it. The example below includes values that I think work best. Use your artistic judgment and adjust accordingly.
\ \ \ \
usepackage[ hang, spl i t r ul e] { f oot m sc} i addt ol engt h{ \ f oot ski p} { 0. 5cm } set l engt h{ \ f oot not em gi n} { 0. 3cm ar } set l engt h{ \ f oot not esep} { 0. 4cm }
And the code for this is, using 100% Column Width as the example:
\ begi n{ f i gur e} [ H] \ capt i on{ i m age t i t l e} \ i ncl udegr aphi cs[ wi dt h=1\ col um nwi dt h] { i m age- f i l e- pat h} \ end{ f i gur e}
The caption is optional, of course.
\ t hi spagest yl e{ em y} pt
This could be quite useful for front pages, where you don't want headers, footers or numbering. On the other hand, the command below will specifically place the headings onto the page, based on your definition in the Preamble.
\ usepackage{ capt i on} \ capt i onset up{ l abel f ont =bf , f or m =pl ai n at , i ndent i on=0cm , j ust i f i cat i on=r aggedr i ght , si ngl el i neche ck=f al se}
This goes into the Preamble:
You will need the caption package to be able to use these settings.
things. It is impossible to explain every little detail, but here's a real-life case:
\ l st set { t absi ze=2, br eakl i nes=t r ue, num be r s=l ef t , basi cst yl e=f oot not esi ze, xl ef t m a r gi n=30pt } \ l st i nput l i st i ng[ l anguage=C, ] { nul l poi nt er . c}
We will read a file called null-pointer.c, which we identify as C language. The default tab size will be two spaces. We will break lines for long pieces of code. Numbers go to the left, 30 points from the page margin, styled in footnote size. Simple, isn't it? A humble example:
Final result:
Trick 9: Watermarks
How about transparent image logos and fancy watermarks? No problem. This can also be done with ease and flair. First, you need to use the watermark package and declare it in the document Preamble.
\ usepackage{ wat er m k} ar
Next, you need to place the watermark where you desire. You can also use the \put command to specify the exact location
of the image. For best effect, it should be a low-contrast, transparent image. For instance:
\ t hi swat er m k{ \ cent er i ng \ put ( 0, ar 660) { \ i ncl udegr aphi cs[ wi dt h= \ t ext wi dt h] { t ux. png} } }
This command tells us to place a watermark based on the tux.png file, on a single page, with vertical offset of 660pt, centered to text width. You can go wild with vertical and horizontal positioning, scaling and whatnot. You can also use the same watermark on all pages, if you like. My example is not that beautiful, but it demonstrates the concept:
You can also use the draftcopy package for DVI and PS output or pdfdraftcopy for PDF output to place a diagonal DRAFT on your pages. For example:
\ usepackage{ dr af t copy}
\ vspace{ 1cm }
Vertical spacing can be useful if you're using multiple columns and want different columns to have a ragged bottom. Combined with \raggedbottom and clear page, vspace can make your elements align with greatest compactness, especially if you have images or tables that break the flow.
Speaking of multiple columns, you can create article with two, three or more columns quite easily. Just use the multicol package. Declare it in the Preamble and then anywhere in your body, switch between single and multiple columns as you see fit:
\ begi n{ m t i col s} { <num ul ber >} cont ent goes her e as usual . . . \ end{ m t i col s} ul
You can alternate between single and multiple columns. For example, you may want to span your images and tables across the page, but use two blocks of text. Just remember that text will span left to right within the block and won't break over into the second multi-column section further below.
Conclusion
There you go. This article is a thermonuclear geek device, but I think it's useful. While my personal experience may not be of any use to you, especially if you've never tried LaTeX before, I hope this article can intrigue you and prompt you into trying. The important lessons we've learned today are: LaTeX can be pimped into any style you want, sometimes with more freedom and elegance than a typical office suite program. LaTeX is a vast and rich world, with a package for pretty
much anything. You can probably clone baby koalas using the right package; it's unto text what repository is unto Linux. Lastly, you gained simple and quick answers to some common issues that may arise during your LaTeX escapades. If you have other cases you consider useful and worthy of covering, or maybe questions that still lay around unanswered, then feel free to mail me, and there might yet be a sequel to this article.