1

I'm writing a document where I need to build a table and put some figures inside. I use pstricks for my figures as I'm most familiar with it. However this is my first time using tables in LaTeX.

So I tried the following code but got an error from the compiler saying there's probably a missing \item :

\documentclass[12pt]{article}

\usepackage{xcolor}
\usepackage{pstricks-add}

\definecolor{rouge}{rgb}{0.93,0.11,0.14}
\definecolor{vert}{rgb}{0.22,0.71,0.29}

\begin{document}

\begin{center}
    \begin{tabular}{ | c | c | c | }
        \hline
            $\varphi$ &
            \textbf{Chronogrames} &
            \textbf{Lissajous (XY)} \\
        \hline
            $0$ &
            \begin{center} % Compiler does not like this line
                \psset{xunit=0.5, yunit=0.5}
                \begin{pspicture}(-3.7,-2.5)(3.7, 2.7)
                    \psaxes[ticks=none, labels=none, showorigin=false]{->}(0,0)(-3.7,-2.5)(3.7, 2.7)[$t$,0][$ $,0]
                    \psplot[algebraic, linecolor=rouge, plotpoints=200]{0}{9}{2.5*cos(x)}
                    \psplot[algebraic, linecolor=vert, plotpoints=200]{0}{9}{1.5*cos(x)}
                    \psline[linecolor=rouge]{|-|}(1, 2.1)(7.283, 2.1)
                    \psline[linecolor=vert]{|-|}(2, 1.8)(8.283, 1.8)
                \end{pspicture}
            \end{center} &
            hello \\
        \hline
    \end{tabular}
\end{center}

\end{document}

The compiler (XeTeX) underlines the line containing the begin of the center environnement around the pspicture environnement. I tried adding braces around this center environnement, but it gaves me the same error.

Can you help me please ? Thanks !

5
  • 2
    I didn't know pstricks understands french ;o). What I would do, personally, would be to compile the pstricks figures as standalone files and include the resulting .pdfs in the tabular environment via \includegraphics.
    – Bernard
    Jul 21 at 8:38
  • 3
    Why do you use center environment in a table cell when you specify c as alignment specifier with tabular?
    – AlexG
    Jul 21 at 8:49
  • 3
    the error is center not pstricks you can not have vertical mode material like center in a one-line c column Jul 21 at 9:09
  • 2
    Use minipage instead of center environment.
    – gigiair
    Jul 21 at 9:17
  • Ok thanks for all of you ! Jul 21 at 18:20
1

Using the suggestion of the user @gigair in your comment with a minipage you can obtain this:

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\usepackage{pstricks-add}
\definecolor{rouge}{rgb}{0.93,0.11,0.14}
\definecolor{vert}{rgb}{0.22,0.71,0.29}
\begin{document}
\begin{tabular}{ | c | c | c | }
        \hline
            $\varphi$ &
            \textbf{Chronogrames} &
            \textbf{Lissajous (XY)} \\
        \hline
            $0$ &
             \begin{minipage}[c]{.5\textwidth}
             \psset{xunit=0.5, yunit=0.5}
             \begin{pspicture}(-3.7,-2.5)(3.7, 2.7)
                    \psaxes[ticks=none, labels=none, showorigin=false]{->}(0,0)(-3.7,-2.5)(3.7, 2.7)[$t$,0][$ $,0]
                    \psplot[algebraic, linecolor=rouge, plotpoints=200]{0}{9}{2.5*cos(x)}
                    \psplot[algebraic, linecolor=vert, plotpoints=200]{0}{9}{1.5*cos(x)}
                    \psline[linecolor=rouge]{|-|}(1, 2.1)(7.283, 2.1)
                    \psline[linecolor=vert]{|-|}(2, 1.8)(8.283, 1.8)
                \end{pspicture}
                \end{minipage}
             &
            hello \\
        \hline
    \end{tabular}
\end{document}

With the value .5 of \begin{minipage}[c]{.5\textwidth} you can adjust the horizontal cell to put the whole graph into.

Using tabu package you can (for example) to have a bit of the space between the graph and the last \hline (see {\tabulinesep=1mm.....}).

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\usepackage{pstricks-add}
\definecolor{rouge}{rgb}{0.93,0.11,0.14}
\definecolor{vert}{rgb}{0.22,0.71,0.29}
\usepackage{tabu}
\begin{document}
{\tabulinesep=1mm
\begin{tabu}{|c|c|c|}
        \hline
            $\varphi$ &
            \textbf{Chronogrames} &
            \textbf{Lissajous (XY)} \\
        \hline
            $0$ &
             \begin{minipage}[c]{.5\textwidth}
             \psset{xunit=0.5, yunit=0.5}
             \begin{pspicture}(-3.7,-2.5)(3.7, 2.7)
                    \psaxes[ticks=none, labels=none, showorigin=false]{->}(0,0)(-3.7,-2.5)(3.7, 2.7)[$t$,0][$ $,0]
                    \psplot[algebraic, linecolor=rouge, plotpoints=200]{0}{9}{2.5*cos(x)}
                    \psplot[algebraic, linecolor=vert, plotpoints=200]{0}{9}{1.5*cos(x)}
                    \psline[linecolor=rouge]{|-|}(1, 2.1)(7.283, 2.1)
                    \psline[linecolor=vert]{|-|}(2, 1.8)(8.283, 1.8)
                \end{pspicture}
                \end{minipage}
             &
            hello \\
        \hline
    \end{tabu}}
\end{document}

enter image description here

2
  • 1
    Thanks so much ! It works now ! Jul 21 at 18:19
  • @AdrienMerat Very happy to help you. :-)
    – Sebastiano
    Jul 24 at 22:19
1

Here is an alternative, that makes use of a p type column, the shift=* option of pspicture and \makegapedcells from the makecell package:

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\usepackage{pstricks-add}
\definecolor{rouge}{rgb}{0.93,0.11,0.14}
\definecolor{vert}{rgb}{0.22,0.71,0.29}
\usepackage{makecell}
\setcellgapes{3pt}
\begin{document}
{\makegapedcells
\begin{tabular}{ | c | p{6.5cm} | c | }
        \hline
            $\varphi$ &
            \textbf{Chronogrames} &
            \textbf{Lissajous (XY)} \\
        \hline
            $0$ &
             \psset{xunit=0.5, yunit=0.5}
             \begin{pspicture}[shift=*](-3.7,-2.5)(3.7, 2.7)
                    \psaxes[ticks=none, labels=none, showorigin=false]{->}(0,0)(-3.7,-2.5)(3.7, 2.7)[$t$,0][$ $,0]
                    \psplot[algebraic, linecolor=rouge, plotpoints=200]{0}{9}{2.5*cos(x)}
                    \psplot[algebraic, linecolor=vert, plotpoints=200]{0}{9}{1.5*cos(x)}
                    \psline[linecolor=rouge]{|-|}(1, 2.1)(7.283, 2.1)
                    \psline[linecolor=vert]{|-|}(2, 1.8)(8.283, 1.8)
                \end{pspicture}
             &
            hello \\
        \hline
    \end{tabular}}
\end{document}
1
  • I don't like an answer with 0 score when it is correct and nice.
    – Sebastiano
    Jul 24 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.