1

I am using casual cv of the moderncv package.

I added an image using the following 2 codes:

\adjustbox{height=1em}{\adjustimage{height=3.5em,valign=t,set depth=0pt}{LOGO1.png}}

and

The solution offered here

With the first code I got: enter image description here

And with the second this: enter image description here

Ideally, I would like to have something like: enter image description here

Any suggestions:


Compilable Code:

\documentclass[11pt,a4paper]{moderncv}
\moderncvtheme[blue]{casual}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{adjustbox}
\usepackage{xcolor}
\usepackage[english,ngerman]{babel}
\usepackage[ansinew]{inputenc}
\usepackage[super]{nth}
\usepackage[scale=0.8]{geometry}
\usepackage{graphicx}
\setlength{\hintscolumnwidth}{3.25cm}


%newcventry
\newcommand{\newcventry}[9][0.25em]{%
    \cvitem[#1]{#2}{%
        \ifthenelse{\equal{#7}{}}%
            {}{%                                        V-V arbitrary space
                \begin{minipage}[t]{\dimexpr\linewidth-#8-1em}%
                \vspace{-0.7em}%
        }%
        {\bfseries#3}% Title
        \ifthenelse{\equal{#4}{}}{}{\newline {\slshape#4}}% Name of the institution
        \ifthenelse{\equal{#5}{}}{}{, {\slshape#5}}% City
        \ifthenelse{\equal{#6}{}}{}{, {\slshape#6}}% Country
        \strut%
        \ifx&#9&% description
            \else{\newline{}\begin{minipage}[t]{\linewidth}\small#9\end{minipage}}\fi
        \ifthenelse{\equal{#7}{}}% image
        {}{%
        \end{minipage}\hfill%
    \begin{minipage}[t]{#8}% width of image
    \vspace{-0.7em}%
    \includegraphics[width=#8]{#7}%
    \end{minipage}%
  }%
  } }


\firstname{John}
\familyname{Doe}
\address{Somewhere}{Along there}
\mobile{+1 (800) 555-5555}
\email{[email protected]} 

\extrainfo{
\parbox{6cm}{
\centering
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~John Doe]{www.xing.com/profile/John_Doe/} 
\httplink[\faGithub~JohnDoe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~John Doe]{stackoverflow.com/users/12345678/john-doe}
}}

\begin{document}
\maketitle

\section{Work Experience}
\cvline{xx.20xx - xx.20xx}{\textbf{Title}\hfill
\adjustbox{height=1em}{\adjustimage{height=3.5em,valign=t,set depth=0pt}{LOGO1.png}}
\newline
\textit{Company, That Location, Fancy City} \newline 
Very long and interesting description of what I did there. Responsible for \underline{\textbf{this}} and \underline{\textbf{that}} - this is just a very very very long text that has no relevance what so ever. Responsible for \underline{\textbf{this}} and \underline{\textbf{that}} - this is just a very very very long text that has no relevance what so ever.}

\newcventry{Date1 - Date2}{Very long name just to make things clearer}{Name of the institution}{Address of the institution}{number 6}{LOGO1.png}{11em}{Very long and interesting description of what I did there. Responsible for \underline{\textbf{this}} and \underline{\textbf{that}} - this is just a very very very long text that has no relevance what so ever. Responsible for \underline{\textbf{this}} and \underline{\textbf{that}} - this is just a very very very long text that has no relevance what so ever.}

\end{document}
3
  • If you want complete control over the placement don't use wrapfig. And don't use the center environment inside of wrapfigure or similar environments such as figure or table.
    – Skillmon
    Jan 22, 2019 at 8:42
  • @Skillmon, okay, if I don't use them, how can I get the desired result?
    – Sami
    Jan 22, 2019 at 8:45
  • 1
    Did you saw question tex.stackexchange.com/questions/413768 ? Duplicate? BTW: \cvline is outdated, now it is \cvitem ...
    – Mensch
    Jan 22, 2019 at 9:00

2 Answers 2

2

New answer

One can use insbox to place the graphic (insbox is similar to wrapfig in it's effect but does so with less ado and therefore exact positioning is easier with it. Still it adds \@InsertBoxMargin on top of the image, which results in imperfect alignment with what you want. So I set \@InsertBoxMargin to 0pt and add the padding myself with the macro \EnlargeBox, which gets 2 aguments. The first is a token list. If that list contains l the box will be enlarge to the left by \InsertBoxMargin, if it contains r to the right. If it contains t on top and if it contains b on the bottom. The second argument is the material which is to be typeset inside of a \hbox.

It will only work for the current \cvline/\cvitem.

\documentclass[11pt,a4paper]{moderncv}
\moderncvtheme[blue]{casual}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{xcolor}
\usepackage[english,ngerman]{babel}
%\usepackage[ansinew]{inputenc}
\usepackage[super]{nth}
\usepackage[scale=0.8]{geometry}
\usepackage{graphicx}
\setlength{\hintscolumnwidth}{3.25cm}
\input{insbox}
\usepackage{grabbox}

\firstname{John}
\familyname{Doe}
\address{Somewhere}{Along there}
\mobile{+1 (800) 555-5555}
\email{[email protected]} 

\extrainfo{
\parbox{6cm}{
\centering
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~John Doe]{www.xing.com/profile/John_Doe/} 
\httplink[\faGithub~JohnDoe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~John Doe]{stackoverflow.com/users/12345678/john-doe}
}}
\makeatletter
\newlength\InsertBoxMargin
\InsertBoxMargin=\@InsertBoxMargin
\@InsertBoxMargin=0pt
\newsavebox\EnlargeBox@box
\long\def\afterfiAn\else#1\fi#2{\fi}
\long\def\afterfiBy\fi#1{\fi#1}
\newcommand\IfTokenInList@define[1]
  {%
    \def\IfTokenInList@test##1#1##2\q@stop
      {%
        \if\relax\detokenize{##2}\relax
          \afterfiAn
        \else
          \afterfiBy
        \fi
      }%
  }
\newcommand\IfTokenInList[2]
  {%
    \IfTokenInList@define{#1}%
    \IfTokenInList@test#2#1\q@stop
  }
\newcommand\EnlargeBox[1]
  {%
    \begingroup
    \grabbox\EnlargeBox@box[\IfTokenInList{l}{#1}{\hskip\InsertBoxMargin}]%
    \hbox[\IfTokenInList{r}{#1}{\hskip\InsertBoxMargin}]%
      {%
        \IfTokenInList{t}{#1}
          {%
            \ht\EnlargeBox@box
              \dimexpr\InsertBoxMargin+\ht\EnlargeBox@box\relax
          }%
        \IfTokenInList{b}{#1}
          {%
            \dp\EnlargeBox@box
              \dimexpr\InsertBoxMargin+\dp\EnlargeBox@box\relax
          }%
        \box\EnlargeBox@box
        \endgroup
      }%
  }
\makeatother



\begin{document}
\maketitle

\section{Work Experience}
\cvline{xx.20xx - xx.20xx}{%
  \InsertBoxR{0}{\EnlargeBox{lb}{\includegraphics[width=.23\textwidth]{example-image-duck}}}
\textbf{Title}
  \newline 
\textit{Company, That Location, Fancy City} \newline 
Responsible for \underline{\textbf{this}} and \underline{\textbf{that}} and
also everything else that is interesting}

\cvline{xx.20xx - xx.20xx}{
\textbf{Title} \newline 
\textit{Company, That Location, Fancy City} \newline 
Responsible for \underline{\textbf{this}} and \underline{\textbf{that}}}
\end{document}

enter image description here


Old answer

Using adjustbox to set the image with zero depth and top aligned. It will not take up vertical space this way, so might overlap with other contents.

\documentclass[11pt,a4paper]{moderncv}
\moderncvtheme[blue]{casual}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{adjustbox}
\usepackage{xcolor}
\usepackage[english,ngerman]{babel}
\usepackage[ansinew]{inputenc}
\usepackage[super]{nth}
\usepackage[scale=0.8]{geometry}
\usepackage{graphicx}
\setlength{\hintscolumnwidth}{3.25cm}

\firstname{John}
\familyname{Doe}
\address{Somewhere}{Along there}
\mobile{+1 (800) 555-5555}
\email{[email protected]} 

\extrainfo{
\parbox{6cm}{
\centering
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~John Doe]{www.xing.com/profile/John_Doe/} 
\httplink[\faGithub~JohnDoe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~John Doe]{stackoverflow.com/users/12345678/john-doe}
}}

\begin{document}
\maketitle

\section{Work Experience}
\cvline{xx.20xx - xx.20xx}{
\textbf{Title}\hfill
\adjustimage{width=.23\textwidth,valign=t,set depth=0pt}{example-image-duck}
  \newline 
\textit{Company, That Location, Fancy City} \newline 
Responsible for \underline{\textbf{this}} and \underline{\textbf{that}}}

\cvline{xx.20xx - xx.20xx}{
\textbf{Title} \newline 
\textit{Company, That Location, Fancy City} \newline 
Responsible for \underline{\textbf{this}} and \underline{\textbf{that}}}
\end{document}

enter image description here

2
  • That worked, until the test was too long, the text then was over the image, is there a way to then make the text automatically start a new line as soon as it hits the image?
    – Sami
    Jan 22, 2019 at 9:09
  • I tried different solutions, but still was not able to do what I want... I edited the question, I hope it is clearer now.
    – Sami
    Jan 22, 2019 at 11:20
0

There is always the right way, and the working way... so I am pretty sure there is a nice solution, more elegant.

Here I simply added a \vspace{-4ex} and removed that wrapfigure.

negative space

\documentclass[11pt,a4paper]{moderncv}
\moderncvtheme[blue]{casual}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{wrapfig}
\usepackage{xcolor}
\usepackage[english,ngerman]{babel}
\usepackage[ansinew]{inputenc}
\usepackage[super]{nth}
\usepackage[scale=0.8]{geometry}
\usepackage{graphicx}
\setlength{\hintscolumnwidth}{3.25cm}

\firstname{John}
\familyname{Doe}
\address{Somewhere}{Along there}
\mobile{+1 (800) 555-5555}
\email{[email protected]} 

\extrainfo{
\parbox{6cm}{
\centering
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~John Doe]{www.xing.com/profile/John_Doe/} 
\httplink[\faGithub~JohnDoe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~John Doe]{stackoverflow.com/users/12345678/john-doe}
}}

\begin{document}
\maketitle

\section{Work Experience}
\cvline{xx.20xx - xx.20xx}{
        \begin{flushright}
        \vspace{-4ex}
        \includegraphics[width=0.23\textwidth]{example-image-a}
        \end{flushright}}
{\vspace{-18ex}
\textbf{Title} \newline 
\textit{Company, That Location, Fancy City} \newline 
Responsible for \underline{\textbf{this}} and \underline{\textbf{that}}

\textbf{Title} \newline 
\textit{Company, That Location, Fancy City} \newline 
Responsible for \underline{\textbf{this}} and \underline{\textbf{that}}
}

\end{document}
3
  • Thank you, but how can I pull the text up as well?
    – Sami
    Jan 22, 2019 at 18:49
  • Like this? Check new edit. However, this solution is not the correct one. Might not work always and might cause problems at the end of the page...
    – G. Bay
    Jan 22, 2019 at 19:45
  • No, not like that. Like this -> i.stack.imgur.com/hU5HK.png
    – Sami
    Jan 22, 2019 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .