0

In the following code, the logo is centered in the framebox. How can I get it aligned to the right?

keepaspectratio, right does not work...contrary to what I found on the net.

Error: "Package xkeyval Error: 'right' undefined in families 'Gin'. \newpage"

\documentclass[11pt,a4paper]{article}
\usepackage{wallpaper}
\usepackage[left=1.3cm,right=4.6cm,top=1.8cm,bottom=4.0cm,marginparwidth=3.4cm]{geometry}
\usepackage{adjustbox}
\usepackage{xcolor}
\usepackage{pdflscape}
\usepackage[useregional]{datetime2}
\usepackage{fancyhdr}
\setlength{\headheight}{80pt}
\pagestyle{fancy}\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\setlength{\parindent}{0cm}
\newcommand\BackgroundStructure{
    \setlength{\unitlength}{1mm}
    \setlength\fboxsep{0mm}
    \setlength\fboxrule{0.5mm}
    \put(10, 10){\fcolorbox{red}{red!10}{\framebox(155,247){}}} % mainr
    \put(165, 10){\fcolorbox{blue}{blue!10}{\framebox(37,247){}}} % margin
    \put(10, 262){\fcolorbox{green}{green!10}{\framebox(192, 25){{\includegraphics[height=23mm,keepaspectratio]{C:/ProgramData/.../.../logo.jpg}}}}} % header
}

\fancyhead[L]{\begin{tabular}{l r | l r} \textbf{Project} & new project & \textbf{Pag.} & \thepage/\pageref{LastPage} \ \textbf{Nr.} & 2020-000A & \textbf{Date} & $\today$ \ \textbf{Program version} & 1.5 & & \ \textbf{Calculated by} & John & \textbf{Company} & \textbf{Doe Chemical}\ \end{tabular}}

%\graphicspath{ logo folder } \begin{document} \AddToShipoutPicture{\BackgroundStructure} \section{Results} \begin{tabular}{lcl} \hline \multicolumn{3}{l}{Limit:}\ vertical: & 2.7 $ \leq$ 18.8 & OK\ Horizontal: & 52.5 $\leq$ 398 & OK\ for class: & 1 & OK\ for class: & 1 & OK\ \multicolumn{3}{l}{State:}\ Geometric stability: & & OK\ \end{tabular} \newpage \end{document}

leandriis
  • 62,593
Erik
  • 167
  • 1
    Place \hfill directly before the \includegraphics command and the image should be right aligned inside of the green box. – leandriis Sep 20 '20 at 10:03
  • What does "keepaspectratio, right does not work...contrary to what I found on the net." refer to? From the quoted error message, I guess, you tried adding right to the optional argument of \includegraphics. Where exactly did you find this information? – leandriis Sep 20 '20 at 10:05
  • I guess, you found the right option for example here: https://tex.stackexchange.com/a/91580/134144. Please be aware, that the adjustbox package in this question is loaded with the export option, an option you did not include. You need this option in order to be able to use key originally defined for \adjustbox with \includegraphics as well. Thus, using \usepackage[export]{adjustbox} should help getting rid of the error message. – leandriis Sep 20 '20 at 10:10
  • @leandriis: I didn't. I tried everything. I still have difficulty in finding the right doc sources. A lot is outdated, new packages seem to appear daily, etc. – Erik Sep 20 '20 at 12:15
  • @leandriis: And second: it seems to work with \hfill AND without export/adjustbox... – Erik Sep 20 '20 at 12:21
  • The only thing needed to get the alignment you want to achieve is indeed the \hfill command. My remarks about adjustbox were ment to explain why you got the error message in the first place. – leandriis Sep 20 '20 at 12:32

1 Answers1

1

Just add an \hfill at the relevant place:

 \put(10, 262){\fcolorbox{green}{green!10}{\framebox(192, 25){{\hfill%
  \includegraphics[height=23mm,keepaspectratio]{pepe-le-pew1.jpg}}}}} 

(I don't have your logo,and I had to replace it with one of mine) enter image description here

Bernard
  • 271,350