3

I have more of a cosmetic sort of problem.

Normally the vertical space between the \bottomrule and the caption looks like this:

enter image description here

But with the code I use, some tables look like this:

enter image description here

I use the following code:

\documentclass[
    12pt, % font size
    ngerman, % german umlaute and german hyphenation
    a4paper, % paper format
    oneside, % one-sided pages
]{article}

% Language
\usepackage[ngerman]{babel} % languages
\usepackage[utf8]{inputenc} % utf8

% Font and Styling
\usepackage[T1]{fontenc} % 8-bit font encoding
\usepackage{lmodern} % better font
\usepackage{titlesec} % enabels the styling of titles, sections etc.
\usepackage{titling} % enables the exact styling of the \maketitle command
\usepackage{textcomp}
\usepackage{gensymb} % defines special symbols

% Page
\usepackage[a4paper,top=25mm,bottom=25mm,left=35mm,right=25mm]{geometry} % page geometry

% Graphics
\usepackage{graphicx} % graphics (jpeg)
\usepackage{subcaption} % for subfigures
\usepackage{tikz} % draw figures

% Tables
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{array} 
\usepackage{ragged2e}


\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

\renewcommand\tabularxcolumn[1]{>{\small}m{#1}}
\newcolumntype{Y}[1]{>{\centering\hsize=#1\hsize\arraybackslash}X}
\newcolumntype{O}[1]{>{\raggedright\hsize=#1\hsize\arraybackslash}X}

\begin{document}
    \selectlanguage{ngerman}

    \begin{table}[h!]
        \centering
        \ra{1.2}
        \begin{tabularx}{\textwidth} {@{} Y{.2} O{1.8} @{}}
            \toprule
            \bfseries{\#} &
            \bfseries{Massnahme} \\
            \midrule
            1 &
            Budgetplanung aktuell halten damit Probleme frühzeitig erkannt werden \\

            2 &
            Algorithmen auf effektiver Umgebung testen und allfällige Alternativen finden \\

            3 &
            Hardwareseitig Webcameinstellungen prüfen. Softwareseitig lichtunabhängige Ergänzungen finden. Z.B Eckenerkennung \\

            4 &
            Alternative Objekterkennung finden \\

            5 &
            Zusätzlich über Kamerabild Rechtsvortritt prüfen \\

            6 &
            Geschwindigkeit verringern \\

            7 &
            Früh mittels Fahrzeuglänge Kurvenfahrt testen \\

            8 &
            Motor ersetzen \\
            \bottomrule
        \end{tabularx}
        \caption{Massnahmen}
        \label{tab:Schlussdiskussion - Massnahmen - Massnahmen}
    \end{table}

\end{document}

Can anybody give me a hint what could cause this problem?

  • 1
    What is \ra, please learn not to use H, and as the others say: post a full minimal example. My guess: caption package with the setting that table captions go on top, this no space above the caption. But that is guess work as we do not have enough detail. – daleif Jan 3 '16 at 11:32
  • 2
    \captionsetup[table]{position=below} – Johannes_B Jan 3 '16 at 11:38
  • 1
    @daleif Did you get a new crystall ball for christmas? ;-) – Johannes_B Jan 3 '16 at 11:41
  • 4
    Possible duplicate of Table Caption below the Table – Johannes_B Jan 3 '16 at 12:15
  • 1
    @Johannes_B I simply don't think it's a duplicate – egreg Jan 3 '16 at 13:26
1

Thanks for adding an MWE. The important point in your code is line

\usepackage{subcaption}

That packages loads internally package caption (see documentation with texdoc subcaption on your terminal/console), so you are able to use the command

\captionsetup[table]{position=below}

to get a better distance between table and heading.

Please see the following (minimalized and pretty printed) MWE:

\documentclass[%
  12pt,    % font size
  ngerman, % german umlaute and german hyphenation
  a4paper, % paper format
% oneside, % one-sided pages
]{article}

% Language
\usepackage[ngerman]{babel} % languages
\usepackage[utf8]{inputenc} % utf8

% Font and Styling
\usepackage[T1]{fontenc} % 8-bit font encoding
\usepackage{lmodern} % better fon

% Page
\usepackage[a4paper,top=25mm,bottom=25mm,left=35mm,right=25mm]{geometry} % page geometry

% Graphics
\usepackage{subcaption} % for subfigures, calls package caption % <=====

% Tables
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{array} 
%\usepackage{ragged2e}

\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\renewcommand\tabularxcolumn[1]{>{\small}m{#1}}
\newcolumntype{Y}[1]{>{\centering\hsize=#1\hsize\arraybackslash}X}
\newcolumntype{O}[1]{>{\raggedright\hsize=#1\hsize\arraybackslash}X}


\begin{document}

\captionsetup[table]{position=below}% <=================================

\selectlanguage{ngerman}

\begin{table}
  \centering
  \ra{1.2}
  \begin{tabularx}{\textwidth} {@{} Y{.2} O{1.8} @{}}
    \toprule
    \textbf{\#} & \textbf{Massnahme} \\
    \midrule
    1 & Budgetplanung aktuell halten damit Probleme frühzeitig erkannt 
        werden \\
    2 & Algorithmen auf effektiver Umgebung testen und allfällige 
        Alternativen finden \\
    3 & Hardwareseitig Webcameinstellungen prüfen. Softwareseitig 
        lichtunabhängige Ergänzungen finden, z.\,B Eckenerkennung \\
    4 & Alternative Objekterkennung finden \\
    5 & Zusätzlich über Kamerabild Rechtsvortritt prüfen \\
    6 & Geschwindigkeit verringern \\
    7 & Früh mittels Fahrzeuglänge Kurvenfahrt testen \\
    8 & Motor ersetzen \\
  \bottomrule
  \end{tabularx}
  \caption{Massnahmen}
  \label{tab:Schlussdiskussion - Massnahmen - Massnahmen}
\end{table}

\end{document}

with the wished result:

enter image description here

So at last the given comment of @Johannes_B was right.

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.