1

As I wrote in the heading, have the following problem: enter image description here

I want this table to be centred in the undermentioned text, and the caption above the table should start with the left margin (flushed left), not with the space as you can see. This is the written code:

\begin{table}[h]
\small
\centering
\captionsetup{justification=justified}
\caption[Stopień spęcznienia]{Dane przedstawiające stopień spęcznienia każdego rodzaju membran. Stopień spęcznienia został obliczony na podstawie wzoru (\ref{eqn:specznienie})}
\begin{tabularx}{\textwidth}{c|c|c|c|c|c|c|}
\cline{2-7}
& ChTPP1 & ChTPP2 & ChTPP3 & ChTPP1HA & ChTPP2HA & ChTPP3HA\\  \cline{1-7} 
\multicolumn{1}{|m{2.4cm}|}{\centering Stopień spęcznienia (\%)} & 1244.24 & 1132.06 & 787.62 & 2588.73 & 1650.25 & 1363.64\\
\cline{1-7}
\end{tabularx}
\label{table:specznienie}
\end{table}
4
  • Does it help if you set \captionsetup{justification=justified,singlelinecheck=false}? Dec 24, 2016 at 13:30
  • Thank you! It helps with the caption, now it's flushed left, but the table is still not centered.
    – barnaba
    Dec 24, 2016 at 13:41
  • @ArashEsbati Please provide a MWE to work with the issue Dec 24, 2016 at 13:43
  • @barnaba - The way you're using tabularx is wrong; your table is wider that your text width; see the answer from Zarko for the correct usage. Dec 24, 2016 at 14:36

2 Answers 2

0

Like this?

enter image description here

If you use tabularx you sould use X column type or its modification (see MWE below). Since table width is equal to text width, it doesn't need be centered in the text. I anticipated, that you like to have equal width of cells with centering content:

\documentclass{article}
\usepackage[showframe]{geometry}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
    \begin{table}[h]
    \small
\captionsetup{justification=justified}
    \caption[Stopień spęcznienia]{Dane przedstawiające stopień spęcznienia każdego rodzaju membran. Stopień spęcznienia został obliczony na podstawie wzoru (\ref{eqn:specznienie})}
\label{table:specznienie}
\begin{tabularx}{\textwidth}{|*{7}{C|}}
    \cline{2-7}
\multicolumn{1}{c|}{}
    & ChTPP1    & ChTPP2    & ChTPP3 & ChTPP1HA & ChTPP2HA  & ChTPP3HA\\  
    \cline{1-7}
Stopień spęcznienia (\%) 
    & 1244.24   & 1132.06   & 787.62 & 2588.73  & 1650.25   & 1363.64   \\
    \hline
\end{tabularx}
    \end{table}
\end{document}

In the case, that you like to have vertically centered cells content, than you should add topreamble

\renewcommand\tabularxcolumn[1]{m{#1}}

With this the table looks as follows:

enter image description here

0
0

Probably this should work:

\begin{center}
\begin{table}[h]
\small
\captionsetup{justification=justified}
\caption[Stopień spęcznienia]{Dane przedstawiające stopień spęcznienia każdego rodzaju membran. Stopień spęcznienia został obliczony na podstawie wzoru (\ref{eqn:specznienie})}
\begin{tabularx}{\textwidth}{c|c|c|c|c|c|c|}
\cline{2-7}
& ChTPP1 & ChTPP2 & ChTPP3 & ChTPP1HA & ChTPP2HA & ChTPP3HA\\  \cline{1-7} 
\multicolumn{1}{|m{2.4cm}|}{\centering Stopień spęcznienia (\%)} & 1244.24 & 1132.06 & 787.62 & 2588.73 & 1650.25 & 1363.64\\
\cline{1-7}
\end{tabularx}
\label{table:specznienie}
\end{table}
\end{center}

enter image description here

2
  • I have done what you wtore, but still the table isn't centered
    – barnaba
    Dec 24, 2016 at 13:42
  • Additionally, if i set begin{flushright} ... end{flushright} nothing is changed at all.
    – barnaba
    Dec 24, 2016 at 13:57

You must log in to answer this question.

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