# Using m-column with PsPicture

According to an older post (see here) I'm trying to center a PsPicture inside a cell. The code I used before (raisebox{0pt}[\height]{...}) doesn't seem to work for this picture as the space above and below the picture are different:

MWE:

\documentclass[a4paper,DIV=15,oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{array}
\usepackage{setspace}
\usepackage{pst-all}
\usepackage{auto-pst-pdf}

\begin{document}
\onehalfspacing
\begin{tabular}{m{6.5cm}m{3cm}}
\toprule
\raisebox{0pt}[\dimexpr\height]{\begin{pspicture}[showgrid=false](1,0)(7,1.2)
\psline*[linewidth=2pt,linecolor=black](3.7,0)(4.3,0)(4,0.32)
\psline[linewidth=1.5pt](2,0.8)(2,0.35)(6,0.35)(6,0.8)
\psframe[linecolor=blue,fillstyle=solid,fillcolor=blue](1.1,0.85)(1.4,1.2)
\psframe[linecolor=blue,fillstyle=solid,fillcolor=blue](1.5,0.85)(1.8,1.2)
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](2.05,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](2.4,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](2.75,1){0.15}
%
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](5.3,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](5.65,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](6,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](6.35,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](6.7,1){0.15}
%
\psline[linewidth=2.1pt](1,0.79)(3,0.79)
\psline[linewidth=2.1pt](5,0.79)(7,0.79)
\end{pspicture}} &
$\displaystyle 2x + 3 = 5$
\\\bottomrule
\end{tabular}
\end{document}

How can I fix it?

Try this:

\documentclass[a4paper,DIV=15,oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{array}
\usepackage{setspace}
\usepackage{pst-all}
\usepackage{auto-pst-pdf}
\newcommand{\CenterObject}[1]{\ensuremath{\vcenter{\hbox{#1}}}}

\begin{document}
\onehalfspacing
\begin{tabular}{m{6.5cm}m{3cm}}
\toprule
\raisebox{0pt}[\dimexpr\height]{
\CenterObject{\begin{pspicture}[showgrid=false](1,0)(7,1.2)
\psline*[linewidth=2pt,linecolor=black](3.7,0)(4.3,0)(4,0.32)
\psline[linewidth=1.5pt](2,0.8)(2,0.35)(6,0.35)(6,0.8)
\psframe[linecolor=blue,fillstyle=solid,fillcolor=blue](1.1,0.85)(1.4,1.2)
\psframe[linecolor=blue,fillstyle=solid,fillcolor=blue](1.5,0.85)(1.8,1.2)
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](2.05,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](2.4,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](2.75,1){0.15}
%
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](5.3,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](5.65,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](6,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](6.35,1){0.15}
\pscircle[linecolor=red,fillstyle=solid,fillcolor=red](6.7,1){0.15}
%
\psline[linewidth=2.1pt](1,0.79)(3,0.79)
\psline[linewidth=2.1pt](5,0.79)(7,0.79)
\end{pspicture}}} &
$\displaystyle 2x + 3 = 5$
\\\bottomrule
\end{tabular}
\end{document}

• Thank you, but why isn't the combination of \raisebox and m-column capable of centering the picture? What's different (internally) when using math mode and \vcenter{\hbox{...}}? – Gotti91 Apr 5 '17 at 17:59
• It also seems like raisebox is no longer needed in your MWE ... – Gotti91 Apr 5 '17 at 18:03
• @Gotti I agree that \raisebox is not needed and unfortunately I do not know the deeper reason why the \vcenter{\hbox{...}} works in many situations. I just use it regularly because it seems to work smoothly. – user121799 Apr 5 '17 at 22:53