2

With the following code :

\documentclass[a4paper,twocolumn]{article}
\usepackage{xskak,adjustbox}
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{parskip}

\begin{document}

\lipsum[5]

\begingroup\setlength{\fboxsep}{0pt} \colorbox{lightgray}{% \begin{tabularx}{\linewidth}{p{0.5\linewidth}@{\extracolsep{\fill}}p{0.46\linewidth}@{}}% \adjustbox{valign=t,width=0.85\linewidth}{\chessboard[setfen=8/8/5K2/2p3Bk/2P1R3/8/8/8 b - - 0 1,tinyboard,margin=false]} & \footnotesize{\lipsum[5]} \end{tabularx}} \endgroup

\lipsum[5]

\lipsum[5]

\lipsum[5]

\end{document}

I get the following result :

result

As you can see the text is not perfectly top aligned with the chessboard on the left side... It is slightly shifted down...

I would like to align the top of the chessboard perfectly with the top of the text on the right, but I couldn't do it... Can you help me please?

Thank you!

halogenr
  • 125
  • switch the order of the keys: \adjustbox{width=0.85\linewidth,valign=t}. And if you still don't like the alignment, change \adjboxvtop, see the documentation. – Ulrike Fischer Feb 28 '23 at 22:29

1 Answers1

1

I would use a solution based on two nested minipages, side by side, both set to the top alignment. adjustbox is very convenient macro, which correctly set the image baseline but it has to be corrected by redefined adjboxvtop.

Here's the code. Note I have added a small padding to the colorbox.

\documentclass[a4paper,twocolumn]{article}
\usepackage{xskak,adjustbox}
\usepackage{lipsum}
\usepackage{parskip}

\renewcommand{\adjboxvtop}{1ex}

\begin{document} \lipsum[5]

\begingroup \setlength{\fboxsep}{3pt} \colorbox{lightgray}{% \begin{minipage}{\dimexpr\linewidth-2\fboxsep} \begin{minipage}[t]{0.5\linewidth} \hspace{0.5em}% \adjustbox{width=0.8\linewidth,valign=t}{% \chessboard[% setfen=8/8/5K2/2p3Bk/2P1R3/8/8/8 b - - 0 1, tinyboard, margin=false, ]} \end{minipage}% \hfill \begin{minipage}[t]{0.46\linewidth} \footnotesize \lipsum[5] \end{minipage} \end{minipage}} \endgroup

\lipsum[5]

\lipsum[5]

\lipsum[5]

\end{document}

enter image description here

Celdor
  • 9,058