# Insert Image in tabularx

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]

\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
\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)]
% ]|
\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}
\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
{+33 555 55 55 55}
{someone@gmail.com}}

\end{document}


The image (can be any QR code) is:

And the result I am getting is the following:

• The command is \includegraphics not \includegrafics but also you should not have the surrounding minipage. – David Carlisle Jun 19 '17 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. – David Carlisle Jun 19 '17 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? – Juan Castillo Jun 19 '17 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 – David Carlisle Jun 19 '17 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 :) – Juan Castillo Jun 19 '17 at 23:17

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

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]

\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
\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)]
% ]|
\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}
\end{tabularx}}}


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

\begin{document}

\part{\makecell[r]{Name \\ Surname}}{\personal