0

I have read a few entries here, but I could not make any of them work for my issue.
I am trying to write a cv in LaTeX and am using a template for it. The Template uses the command "cvitem" with two entries (\cvitem {one}{two}).

But in one case, the first item is a longer word, messing up the allignment:

allignment issue

In the Picture you can see that the first entry exceeds the first column, but not readjusting the table, hence causing the allignment in the first column, first row being messed up. Any ideas?

Command for first row: \cvitem{Staatsangehörigkeit}{{\small{}Deutsch}}

Minimal LaTeX Code, overleaf gives me a undefined control sequence error, but compiles it just fine. The Full CV does not display such error:

%% LyX 2.1.4 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[11pt,ngerman]{moderncv}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{graphicx}
% required
\firstname{a}
% required
\familyname{b}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\moderncvtheme[blue]{classic}
\usepackage{babel}
\begin{document}
\section{Persönliche Daten}
\cvitem{Geschlecht}{{Männlich}}
\cvitem{Staatsangehörigkeit}{{\small{}Deutsch}}
\cvitem{Geschlecht2}{{Männlich2}}
\end{document}
Barry
  • 53
  • It's hard to tell without knowing what the template is and how \cvitem is defined. And what is the \small{} for? – Plergux Oct 12 '20 at 11:51
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – DG' Oct 12 '20 at 11:51
  • added a minimal latex code. Overleaf shows an undefined control sequence error, but compiles anyway. And just for the record, the question was just as clear as previously.... – Barry Oct 12 '20 at 12:00
  • @Barry Tried compiling it with pdfLatex in TeXworks, no luck. Got undefined control sequence error, which tends to end things for my documents so that I need to fix something to make it work. And yes, the question was clear, but generally the work required to bring out all the information needed is expected to be done by the person asking the question, not those who want to help. E.g. finding out what document class it is, inspecting \cvitem, creating a document to test within, etc. – Plergux Oct 12 '20 at 13:04
  • @Plergux fixed the latex code. Now works fine in overleaf for me – Barry Oct 12 '20 at 13:06
  • 1
    @Barry Thanks, it compiles fine now. However, I must admit that I'm stumped. Apart from the fact that the word "Staatsangehörigkeit" is too big for the predefined cvcolumn width (\small Staatsangehörigkeit, and Statsangehör. work) I can't for the life of me figure out how to fix this. Hopefully somebody better than me will pick this up. – Plergux Oct 12 '20 at 14:31
  • 1
    @Plergux thanks for trying – Barry Oct 12 '20 at 14:49
  • When I run your code, there is no alignment problem, rather "Staatsangehörigkeit" is hyphened and broken over two lines – DG' Oct 12 '20 at 19:10

2 Answers2

1

In the moderncv.cls you can find the definition of \cvitem as \newcommand*{\cvitem}[3][.25em]{} This means: Make a new command which takes three parameters. The first "spacing" has a default of 0.25em.

It also states that you can use the command as such: \cvitem[spacing]{header}{text}

Therefore adding something like \cvitem[0.5em]{Geschlecht}{Männlich} should do the trick. Of course one could experiment with calculating the ideal width, but I think for a CV this would be over the top.

You can of course experiment with the value to fit your needs. "em" is a tex unit of measurement

I bet you had an overflow warning during compile

Martin H
  • 18,164
  • no, adding that option only affects vertical spacing – Barry Oct 12 '20 at 13:50
  • also if you read my requirement: "Working minimal example where the horizhontal spacing is fixed and can automatically applied to all cvitem-tags" – Barry Oct 12 '20 at 13:50
1

The word "Staatsangehörigkeit" in your example is too long for the column and gets hyphenated:

enter image description here

You can change the column width by setting \hintscolumnwidth to a more appropriate length:

\documentclass[11pt,ngerman]{moderncv}
\usepackage{babel}

\firstname{a} \familyname{b} \moderncvtheme[blue]{classic} \setlength{\hintscolumnwidth}{0.3\textwidth}

\begin{document} \section{Persönliche Daten} \cvitem{Geschlecht}{Männlich} \cvitem{Staatsangehörigkeit}{Deutsch} \cvitem{Geschlecht2}{Männlich2} \end{document}

enter image description here

DG'
  • 21,727