0

I would like to create a fixed width, single column tabularx with centered text which is entirely enclosed. For some reason the width of the cell does not take the table with.

How can I archieve this goal?

Thanks!

\documentclass{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}

\begin{document}

{\renewcommand{\arraystretch}{1.5}
    \begin{minipage}{\linewidth}
        \begin{center}
            \begin{tabularx}{5cm}{|c|}
                \hline
                First Argument\\ \hline
                Second long Argument\\ \hline
                Third Argument\\ \hline
            \end{tabularx}
        \end{center}
    \end{minipage}

\end{document}

singlecolumntabular

  • What is the point in using tabularx if yiou just have one singe column and not even using an Xcolumn? Instead of c, use X? – Johannes_B Mar 14 '16 at 10:21
  • or p{5cm}. Either way, you have to center the content. – Johannes_B Mar 14 '16 at 10:23
  • how to center the content when using X or p? – Eric Mar 14 '16 at 10:26
  • I am open for a solution to solve this in tabular also! – Eric Mar 14 '16 at 10:26
  • There is no point in a single column table, and no point in a tabularx with no X column. What is the intended behaviour here? – David Carlisle Mar 14 '16 at 12:44
1

erikTabularx

\documentclass{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{array}

\begin{document}
\blindtext

\begin{center}
\begin{minipage}{\linewidth}
    \centering
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|>{\centering\arraybackslash}p{5cm}|}
            \hline
            First Argument\\ \hline
            Second long Argument\\ \hline
            Third Argument\\ \hline
        \end{tabular}
\end{minipage}
\end{center}

\blindtext
\end{document}
  • that's it! I was not aware of the \arraybackslash! – Eric Mar 14 '16 at 10:32

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.