1

I would like to center qrcode in cventry. Implemented solution (quad + qrcode) could be replaced.

Current code (MWE):

\documentclass[11pt,a4paper,sans]{moderncv}  
\moderncvstyle{classic}                                                  
\usepackage[scale=0.87]{geometry}
\usepackage{qrcode}
\name{}{}      

\begin{document}

\section{Lorem ipsum}
\cventry
{Lorem -- ipsum}
{dolor sit amet}{}{}{}
{a urna ut auctor. Proin venenatis lacus vitae eros posuere, id pretium tortor rutrum. Donec ac auctor nunc. Suspendisse libero nibh, iaculis blandit tellus ac, faucibus euismod purus. Sed quis lacus vel nunc dictum aliquet. Sed hendrerit ultrices nisi non facilisis.
\quad
\qrcode[height=0.5in]{qrcode message}
\qquad
}
\end{document}

Current state: Current

State i would like to achieve: Correct

I was trying to use

\hfill 

but without success.

Werner
  • 603,163
wdeb
  • 13

1 Answers1

0

You can set the text argument within a [t]op-aligned \parbox that has a pre-specified width (of exactly \linewidth-.5in-1em, leaving .5in for the QR code on the right, as well as a \quad or 1em gap):

enter image description here

\cventry
  {Lorem -- ipsum}
  {dolor sit amet}
  {consectetur}
  {adipiscing, elit}
  {\newline\textbf{Nullam:} mattis}
  {\parbox[t]{\linewidth-.5in-1em}{\strut
    a urna ut auctor. Proin venenatis lacus vitae eros posuere, id pretium tortor rutrum. 
    Donec ac auctor nunc. Suspendisse libero nibh, iaculis blandit tellus ac, faucibus euismod purus. 
    Sed quis lacus vel nunc dictum aliquet. Sed hendrerit ultrices nisi non facilisis.\strut}\hfill
    \raisebox{-\height+.7\baselineskip}[0pt][0pt]{\qrcode[height=0.5in]{qrcode message}}%
  }

The QR code is "raised" to align at the top of the \parbox. Note the use of \strut at the start and end of the \parbox content in order to ensure a consistent baseline skip.

I used template.tex as base for the above example.

Werner
  • 603,163