# CV in LaTeX with moderncv

It’s easy:

\documentclass[11pt,a4paper]{moderncv}

% moderncv themes
\moderncvcolor{grey} % color options 'blue' (default), 'orange', 'green', 'red', 'purple', 'grey' and 'black'
\moderncvstyle{casual} % style options are 'casual' (default), 'classic', 'oldstyle' and 'banking'

\firstname{Max}
\familyname{Mustermann}
\phone{ (01\,23)~45\,67\,89\,00}
\email{me@myself.de}
\photo[64pt]{myself}

\begin{document}
\maketitle

\section{Education}
[...]
\end{document}


I had the problem that when you specify months and years instead of only years, the left margin is too small. You can adjust that with these two lines:

\setlength{\hintscolumnwidth}{0.25\textwidth}
\AtBeginDocument{\recomputelengths}


Also, the languages take up a lot of space, you can just put it into two columns to save space. This is better than the cvdoubleitem in my opinion, because you are more flexible to change the order. I suppose you can still add the comment, if you need to, try it out.

\begin{multicols}{2}
\cvitem{Language 1}{Skill level}
[...]
\end{multicols}


# Sorting a HashMap by Value in Java

Sometimes Java drives you nuts… you want to save word bigrams and their frequencies as an example. A HashMap<String, Integer> is very convenient. Now we want to sort it by value. And the fun begins! Of course we do not want to lose the connection between keys and values, so we cannot just use Collections.sort(map.keySet()) (or the same for values). Also using a TreeMap with a custom-wrote Comparator for our pairs does not work, because there you cannot have identical values (another fun fact).

Here is a generic method that sorts the given HashMap by value. V can be anything as long as it can be compared with itself.

public static <K, V extends Comparable<V>> List<Entry<K, V>> sortHashMapByValue (HashMap<K, V> theMap) {
List<Entry<K, V>> resultList = new ArrayList<Entry<K, V>>(theMap.entrySet());
Collections.sort(resultList,
new Comparator<Entry<K, V>>() {
@Override
public int compare(Entry<K, V> o1, Entry<K, V> o2) {
return o1.getValue().compareTo(o2.getValue());
}
});
return resultList;


# Letters in LaTeX

My standard letter in LaTeX with the class scrlttr2 (created by a German to adhere to German letter guidelines):
 \documentclass[fromalign=location, fromphone=true, fromemail=true, locfield=wide]{scrlttr2} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \setkomavar{fromname}{Max Mustermann} \setkomavar{fromaddress}{Musterstr.\ 1\\12345 Musterstadt} \setkomavar{fromphone}{01234/56789000} \setkomavar{fromemail}{mustermx@provider.xy} \setkomavar{signature}{Max Mustermann} \setkomavar{subject}[]{} \setkomavar{date}{7.\ August 2013}

 

\begin{document} \begin{letter}{Jane Doe\\ Example street 2\\ 54321 Exampleville } \opening{Dear Mrs.\ X,} this is the letter I promised. \closing{Kind regards,} \end{letter} \end{document} 

The variables ‘from…’ set the sender, the recipient is given right after begin letter. The sender information can be set at strange places, for a very simple letter I use ‘fromalign=location’ which results in the sender information somewhere at the top right, a bit higher than the recipient, but not in the headline. With the standard settings the e-mail address is too wide for the sender field, so I widen it with ‘locfield=wide’.