Indent first paragraph of the section in Latex
By default Latex indents all the paragraphs except the first paragraph of the section. To modify this behavior include the indentfirst package in your document’s preamble:
\usepackage{indentfirst}
Linux, SW, networking and more!
Archive for the ‘latex’ Category.
By default Latex indents all the paragraphs except the first paragraph of the section. To modify this behavior include the indentfirst package in your document’s preamble:
\usepackage{indentfirst}
To add new packages to your Mactex installation follow these steps:
$ mkdir ~/Library/texmf/tex/latex/newpackage/ $ cp newpackage.sty ~/Library/texmf/tex/latex/newpackage/
That’s it. No need to re-index package list or something.
I’m using Doxygen to document some C source code. This tool generates multiple sections in the Latex document (one for each variable). These sections are empty (i.e. they only have a title, no text). The problem is that Latex doesn’t automatically break the page when it should, and the section titles go beyond the margins (in fact many titles are not displayed at all).
To solve the issue add the following code to the document’s preamble:
1 2 3 | \makeatletter \renewcommand\@afterheading{} \makeatother |
The \def command provides macro definition in Latex. These definitions are quite useful if you need to repeat some text across the document. For instance you can define a macro containing your document’s title and then use it in the document this way:
% macro definition in the preamble \def \doctitle {This is my document's title}
% Using the previously defined macro in the document This document, titled \doctitle , deals with ...
Sometimes you need more section levels in your Latex document. With little effort you can get up to 5 section levels (the equivalent of a \subsubsubsubsection command), just include the following command in the preamble:
1 | \setcounter{secnumdepth}{5} |
To get the fourth and fifth levels use \paragraph and \subparagraph respectively. The sectioning hierarchy remains as follows:
1 2 3 4 5 | \section{First level} \subsection{Second level} \subsubsection{Third level} \paragraph{Fourth level} \subparagraph{Fifth level} |
Today I tried to extract documentation from source code programmed in Visual Studio using doxygen. The Latex document didn’t compile correctly because of encoding problems. Googling for a solution I’ve discovered that Visual Studio may include some strange characters in the saved files.
To fix the files I’d recommend using an Hexadecimal Editor. In my case I’ve chosen hexedit. Opening the file with Hexedit shows those unwanted characters at the beginning of the file. By removing them and saving the file the problem with Latex disappeared. Hope it helps in case someone runs into the same issue.

To include less than (<) and greater than (>) symbols in your Latex document enclose them in dollar signs:
This is the less than symbol $<$ and this is the greater than $>$ symbol.
The ifthen package allows conditional blocks on Latex documents. This is very useful if you want to include or exclude some parts of the text. To use the package add the following to the document preamble:
\usepackage{ifthen} \newboolean{DEBUG} \setboolean{DEBUG}{false}
Then you can use \ifthenelse commands within the document to include/exclude parts of text. In this example, as the DEBUG variable is set to false, the debug text won’t appear in the final document. If we switch its value to true, the debug text will appear again.
\ifthenelse {\boolean{DEBUG}} {This is some debug text} {This is the other text}
I post source code snippets quite often and I use this plugin for syntax highlighting. It works great but it doesn’t support every programming language. For example it lacks Latex support. On the other hand you can define coloring rules for unsupported languages by creating new “brushes”.
Taking advantage of this feature, I’ve defined an extremely simple Latex brush which highlights:
You can download the brush from here.
If you want to see Latex coloring in action, you can take a look at the Latex section of my blog.
Note: I also had to add this line:
'Latex' => array('latex', 'tex'),
…to the SetVariables() function in syntaxhighlighter.php for the new brush to work.
The wrapfig package enables text wrapping around figures.
\usepackage{wrapfig}
To include a wrapped figure we can use the \begin{wrapfigure} command. You have to specify the alignment (l, r) and the figure’s width. Here is an example:
\begin{wrapfigure}{r}{60mm} \begin{center} \includegraphics[scale=0.5]{images/nature_photography.jpg} \end{center} \caption{Wrapped image.} \end{wrapfigure}
And the final result.
