3

I'm trying to align and image and some lines of text (not a paragraph) to resemble this. enter image description here

this is my code:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[10pt]{moresize}
\usepackage{graphicx}
\usepackage[a6paper]{geometry}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{wrapfig}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{soul}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{fontspec}

\definecolor{blu1000}{RGB}{15, 57, 101}
\definecolor{marrone1000}{HTML}{a4895e}
\definecolor{marronescuro1000}{HTML}{483a26}

\begin{document}            
\vspace*{-5\baselineskip}
\null\hfill {\color{marrone1000} \tiny Certificato d'iscrizione} \\ [\baselineskip]

\vspace*{2\baselineskip}
\centering
\includegraphics[height=2.5cm]{img-1} \\ [\baselineskip]
\color{marrone1000}{
    \noindent\framebox[3cm][c]{\color{blu1000}\textbf{N. 1001-P}}
    \noindent\framebox[3cm][c]{\color{blu1000}\textbf{1001-P-YY-YY}} \\ [.15\baselineskip]
}
\raggedright \hspace{2.5em}\tiny \color{marrone1000}  Identification Number \hspace{5.7em}\tiny Certificate Number \\ [\baselineskip]
\centering
\color{blu1000}{
    \noindent\framebox[6cm][c]{\normalsize\color{blu1000}\textbf{Class Winner}} \\ [.15\baselineskip]
    \raggedright \hspace{5em}\tiny Category \\ [3\baselineskip]
}

\vspace{5\baselineskip}

\begin{wrapfigure}{l}{.4\textwidth}
    \vspace{-24pt}
    \hspace{-14em}
    \centering
    \includegraphics[width=0.40\textwidth]{default_qrcode}
    % \vspace{-20pt}
\end{wrapfigure}

\textcolor{blu1000}{CERTIFICATE} \\ [2\baselineskip]
\color{marrone1000}{
    \noindent \rule{3cm}{0.4pt} \\ [0.15\baselineskip] \hspace{-6em}{Date of Issue \\ [2\baselineskip]}
    \noindent \rule{3cm}{0.4pt} \\ [0.15\baselineskip] \hspace{-6em}{Expiry Date\\ [2\baselineskip]}
}
\clearpage
\end{document}

Resulting enter image description here

I'm using XeLatex and I'd like to left align the text as in 1

2
  • welcome to tex.se! please extend your code snippet to complete small document which we can test as it is. why do you use wrapfigure?
    – Zarko
    Commented Nov 12, 2018 at 23:47
  • Hello, thanks @Zarko for the welcome. I've added the code of the page where it should be. I'm using wrapfigure because I wanted to align the image and text and after googling a lot, I was told that this was the correct way, but as you can see had to fix some spacing... would gladly remove that if I could do it better... Thanks Commented Nov 13, 2018 at 0:00

1 Answer 1

3

see if the following solution is acceptable to you:

\documentclass{article}
\usepackage[showframe,          % <--- in real document delete option "showframe"
            a6paper]{geometry}
\usepackage{fontspec}

\usepackage{xcolor}
\definecolor{marrone1000}{HTML}{a4895e}

\usepackage[10pt]{moresize}
\usepackage[demo,               % <--- in real document delete option "demo"
            export]{adjustbox}  % <--- it load the graphicx package

\begin{document}
    \begin{center}
\begin{minipage}[t]{0.3\linewidth}\centering
    \includegraphics[height=2.5cm, width=\linewidth,valign=t]{img-1}
\end{minipage}
\quad
\begin{minipage}[t]{0.3\linewidth}\raggedright
            CERTIFICATE         \\[1.5\baselineskip]
\tiny
\color{marrone1000}
\rule[-0.5ex]{\linewidth}{0.2pt}
            Date of issue:     \\[1.5\baselineskip]
\rule[-0.5ex]{\linewidth}{0.2pt}
            Expire date
\end{minipage}
    \end{center}
\end{document}

as you can see, i reduce your document example to mwe (minimal working example), which produce result similar to the first image in your question.

edit: for aligning of image in the first minipage it is necessary to move its baseline from its middle to the top. this is done by use of the adjustbox with option export. This package also load the graphicx package.

enter image description here

(lines around image and text shows page layout)

1
  • Awesome! thanks a lot, that's it. Most of the code you saw was because I just came into XeTeX from pure LaTex but I'm liking this more. Thanks again. Commented Nov 13, 2018 at 0:50

You must log in to answer this question.

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