1

I need two boxes in one line which each contains a text on the left side and a QR code on its right.

As this, I started with:

\documentclass[a4paper]{article}
\usepackage{xcolor}
\usepackage{qrcode}
\begin{document}

\fcolorbox{black}{white}{% \begin{minipage}[t]{3cm} \noindent Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text \end{minipage} \hspace{1cm} \begin{minipage}[t]{2cm} \qrcode{https://www.wetteronline.de/wetter/duisburg} \end{minipage} } \hfill \fcolorbox{black}{white}{% \begin{minipage}[t]{3cm} \noindent Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text \end{minipage} \hspace{1cm} \begin{minipage}[t]{2cm} \qrcode{https://www.wetteronline.de/wetter/duisburg} \end{minipage} }

\end{document}

But this generates two problems for me:

  1. The text has a lot of space on top inside each of the boxes. I want the boxes to be filled with the text and the QR code without any additional space on top.

  2. both boxes are places not in a single line, they are placed mid on the page and one at top and one bellow.

Can anyone hint how to place the boxes and remove the unwanted space before the text?

I use pdflatex to create my pdf.

Klaus
  • 155
  • Why are you using \minipage…\endminipage instead of \begin{minipage}…\end{minipage}? If you don't want the boxes side by side, why do you add an empty line = new paragraph between them? – cabohah Jun 08 '23 at 10:52
  • unrelated but please do not use commands like \minipage \endminipage. Use the proper environments. – Ulrike Fischer Jun 08 '23 at 10:52
  • Please read https://tex.stackexchange.com/questions/34166/understanding-minipages-aligning-at-top – cabohah Jun 08 '23 at 10:53
  • @cabohah: fixed the \begin{minipage}, also removed the stupied empty line which was really the problem. Thanks. Still open: the space in front of the text inside each of the boxes. – Klaus Jun 08 '23 at 11:01
  • @cabohah: I read now also https://tex.stackexchange.com/questions/34166/understanding-minipages-aligning-at-top, but as you see all my minipages uses the [t] as parameter, but text is still wrong aligned. I didn't catch the point. Need some help again! – Klaus Jun 08 '23 at 11:15
  • But the baseline of a \qrcode is in the middle. So you have to use, e.g., the package recommended in David Z's answer to change the alignment of minipage and \qrcode or \raisebox to move the baseline. – cabohah Jun 08 '23 at 11:18
  • @cabohah: I now set the minipage with the qrcode in the adjustbox and it works! Thats heavy! :-) Perfect! Thank you! – Klaus Jun 08 '23 at 11:28

1 Answers1

1

The \qrcode is set with its reference point (almost) vertically centered. You can use adjustbox to move it.

\documentclass[a4paper]{article}
\usepackage{xcolor}
\usepackage{qrcode}
\usepackage{adjustbox}

\begin{document}

The baseline _\qrcode{https://www.wetteronline.de/wetter/duisburg}_

\bigskip

\fbox{% \begin{minipage}[t]{3cm} Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text Some dummy text \end{minipage}\hspace{1cm}% \adjustbox{valign=t}{\qrcode{https://www.wetteronline.de/wetter/duisburg}}% }

\end{document}

enter image description here

egreg
  • 1,121,712