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

6
  • 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
    Commented Mar 14, 2016 at 10:21
  • or p{5cm}. Either way, you have to center the content.
    – Johannes_B
    Commented Mar 14, 2016 at 10:23
  • how to center the content when using X or p?
    – Eric
    Commented Mar 14, 2016 at 10:26
  • I am open for a solution to solve this in tabular also!
    – Eric
    Commented Mar 14, 2016 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? Commented Mar 14, 2016 at 12:44

1 Answer 1

3

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}
1
  • that's it! I was not aware of the \arraybackslash!
    – Eric
    Commented Mar 14, 2016 at 10:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .