2

I am trying to insert an image in a tabularx using \insertgraphics{} and none of the solutions that I found on the internet seem to work. To do this, I am using a class with several commands, that are then called in the Latex Document.

The command to create the image is hardcoded in the class, and the image is inside a folder named img. I am getting several errors but the first one is !Undefined control sequence.

The class that I use is the following:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv}
              [2012/11/09 v1.0
 Two Column Curriculum Vitae]

\LoadClass[10pt]{scrartcl}

\setcounter{secnumdepth}{-1}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{bookman,etoolbox,hyperref,needspace,tabularx,xcolor,fontawesome,makecell,graphicx}

\pagestyle{empty}
\setlength\parindent{0pt}
\color[HTML]{303030} % Default foreground color
\definecolor{link}{HTML}{506060} % Hyperlinks
\hypersetup{colorlinks,breaklinks,urlcolor=link,linkcolor=link}
\setkomafont{disposition}{\color[HTML]{0058B6}}
\setkomafont{section}{\scshape\Large\mdseries}

% In tccv \part must contain the subject of the curriculum vitae.
% The command will start a new page and output in onecolumn the
% subject (first and last name) with the hardcoded text
% "Curriculum vitae" under it.
\renewcommand\part[2]{%
  \twocolumn[%
    \vskip-\lastskip%
    \begin{tabularx}{\linewidth}{ c@{\hskip 0.25in} | X | X }
      {\usekomafont{part} \hfill #1} & {#2} & {\begin{minipage}{0.45\textwidth}\includegrafics[width=\textwidth]{img/qrcode.png}\end{minipage}}
    \end{tabularx}
    \bigskip]}

% Renders a personal data box:
%
% |[
% \personal[optional: web site without scheme (no http:// prefix)]
%          {address}{phone number}{email}
% ]|
\newcommand\personal[4][]{%
    %\needspace{0.5\textheight}%
    \newdimen\boxwidth%
    \boxwidth=\dimexpr\linewidth-2\fboxsep\relax%
    \colorbox[HTML]{C7E2F2}{%
    \begin{tabularx}{\boxwidth}{c X}
    \faMapMarker  & {#2}\smallskip\\
    \faPhone     & {#3}\smallskip\\
    \faEnvelope      & \href{mailto:#4}{#4}
    \ifstrempty{#1}{}{\smallskip\\ \faLinkedin & \href{http://www.#1}{#1}}
    \end{tabularx}}}

The latex document I am using is:

\documentclass{tccv}
\usepackage[english]{babel}
\usepackage{fontawesome}
\usepackage[gen]{eurosym}

\begin{document}

\part{\makecell[r]{Name \\ Surname}}{\personal
    [linkedin.com]
    {Address }
    {+33 555 55 55 55}
    {[email protected]}}

\end{document}

The image (can be any QR code) is: enter image description here

And the result I am getting is the following:enter image description here

5
  • The command is \includegraphics not \includegrafics but also you should not have the surrounding minipage. Commented Jun 19, 2017 at 21:46
  • you presumably got an error about an undefined command, do not ignore error messages, after an error you should not look at the pdf at other than possible use for debugging. Commented Jun 19, 2017 at 21:48
  • That was really dumb from my part :( Thanks for pointing out the mistake! To avoid being a useless post, do you know a simple way of vertically aligning the image? Commented Jun 19, 2017 at 22:20
  • easiest way is to use adjustbox package with its option to add extra keys to \includegraphics then you can specify things like valign=t Commented Jun 19, 2017 at 23:08
  • Great I will try it out. Thanks for helping this newbie in Latex hehe. If you want to post the comment as an answer I will mark it as solved :) Commented Jun 19, 2017 at 23:17

2 Answers 2

1

The command is \includegraphics not \includegrafics but also you should not have the surrounding minipage

If you want to control alignment as mentioned in comments easiest way is to use adjustbox package with its option to add extra keys to \includegraphics then you can specify things like valign=t

1

In his comment, @DavidCarlisle has already given you the idea. Here is a modified .cls file with the required corrections.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv}
              [2012/11/09 v1.0
 Two Column Curriculum Vitae]

\LoadClass[10pt]{scrartcl}

\setcounter{secnumdepth}{-1}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{bookman,etoolbox,hyperref,needspace,tabularx,xcolor,fontawesome,makecell,graphicx}
\RequirePackage[export]{adjustbox}

\pagestyle{empty}
\setlength\parindent{0pt}
\color[HTML]{303030} % Default foreground color
\definecolor{link}{HTML}{506060} % Hyperlinks
\hypersetup{colorlinks,breaklinks,urlcolor=link,linkcolor=link}
\setkomafont{disposition}{\color[HTML]{0058B6}}
\setkomafont{section}{\scshape\Large\mdseries}

% In tccv \part must contain the subject of the curriculum vitae.
% The command will start a new page and output in onecolumn the
% subject (first and last name) with the hardcoded text
% "Curriculum vitae" under it.
\renewcommand\part[2]{%
  \twocolumn[%
    \vskip-\lastskip%
    \begin{tabularx}{\linewidth}{ c@{\hskip 0.25in} | X | X }
      {\usekomafont{part} \hfill #1} & {#2} & {\includegraphics[width=.1\textwidth,valign=m]{example-image}}
    \end{tabularx}
    \bigskip]}

% Renders a personal data box:
%
% |[
% \personal[optional: web site without scheme (no http:// prefix)]
%          {address}{phone number}{email}
% ]|
\newcommand\personal[4][]{%
    %\needspace{0.5\textheight}%
    \newdimen\boxwidth%
    \boxwidth=\dimexpr\linewidth-2\fboxsep\relax%
    \colorbox[HTML]{C7E2F2}{%
    \begin{tabularx}{\boxwidth}{c X}
    \faMapMarker  & {#2}\smallskip\\
    \faPhone     & {#3}\smallskip\\
    \faEnvelope      & \href{mailto:#4}{#4}
    \ifstrempty{#1}{}{\smallskip\\ \faLinkedin & \href{http://www.#1}{#1}}
    \end{tabularx}}}

Now, compiling your code:

\documentclass{tccv}
\usepackage[english]{babel}
\usepackage{fontawesome}
\usepackage[gen]{eurosym}

\begin{document}    

\part{\makecell[r]{Name \\ Surname}}{\personal
    [linkedin.com]
    {Address }
    {+33 555 55 55 55}
    {[email protected]}}    

\end{document}

gives this result:

enter image description here

You must log in to answer this question.

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