3

Dear TeX Stackexchange

I have one issue, when I create my table. As you can see on the picture below, the three black lines don't go to the right but stops under (10):

enter image description here

My text look like this:

        \documentclass[a4paper,11pt,twoside]{report}
        \usepackage[utf8]{inputenc}
        \usepackage[english]{babel} 
        \usepackage{layout}
        \usepackage[protrusion=true,expansion=true]{microtype} 

        % Different usepackages
        \usepackage[T1]{fontenc}
        \usepackage[lf]{MinionPro} %% MinionPro
        \usepackage{icomma}
        \usepackage{setspace}
        \setstretch{1.10}
        \usepackage{siunitx,booktabs}
        \usepackage{graphicx}

        % Page margins
        \usepackage[left=3.5cm,right=3.5cm,top=3.4cm,bottom=3.4cm]{geometry}

        % Tabular
        \usepackage{threeparttable}
        \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
        \includepdfset{pagecommand=\thispagestyle{plain}}
        \renewcommand{\TPTnoteSettings}{\footnotesize}
        \renewcommand{\TPTnoteLabel}[1]{#1}

        \usepackage{float}

        % Rotate
        \usepackage{pdflscape}

        \begin{document}
   \begin{landscape}      
            \begin{table}[H]
            \begin{threeparttable}
            \renewcommand\arraystretch{1.1}
            \medskip
            \renewcommand\tabcolsep{1pt}  % Set this to some very small value ...
            \begin{tabular*}{\textwidth}{ @{} p{2.4cm} 
                 @{\extracolsep{\fill}}   % and let LaTeX provide the necessary "fill" amount
                 *{12}{S[table-format=2.3]} @{}}
            \toprule
            \emph{?} 
            & \multicolumn{4}{c}{Room1} 
            & \multicolumn{4}{c}{Room2} 
            & \multicolumn{4}{c}{Room3} 
             \\
            \cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
            & {(1)} & {(2)} & {(3)} & {(4)} 
            & {(5)} & {(6)} & {(7)} & {(8)}
            & {(9)} & {(10)} & {(11)} & {(12)} \\
            \emph{Dep.\ var.}
            & {Elec} & {Elec} & {Elec} & {Elec} 
            & {Elec} & {Elec} & {Elec} & {Elec} 
            & {Elec} & {Elec} & {Elec} & {Elec} \\
            \midrule
            \emph{Undep.\ var.}\\
            Electricity
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}}  
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}}  
            \\
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            \\
            Ohm 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}}  
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}} 
            & \multicolumn{1}{c}{0,00\sym{***}}  
            \\
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            & \multicolumn{1}{c}{(0,00)} 
            \\ 
            \cmidrule{1-1}
            R\textsuperscript{2} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00}  
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00} 
            & \multicolumn{1}{c}{0,00}  
            \\ 
            N 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000}
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000} 
            & \multicolumn{1}{c}{000}
            \\ 
            \bottomrule
            \end{tabular*}
            \end{threeparttable}
            \end{table}
        \end{landscape}
        \end{document}

I can't figure out what I am doing wrong. If you can see, what I am doing wrong or help me by fixing it - I would appreciate that help very much!

EDIT: New Table

    \begin{table}[H]
    \centering
    \begin{threeparttable}
    \renewcommand\arraystretch{1.1}
    \medskip
    \begin{tabular*}{0.82\textwidth}{
      @{\extracolsep{\fill}}
      l
      c
      S[table-format=3.0]
      S[table-format=3.0]
    }
    \toprule
    & {Randomized$^{\pm}$} & {Electricity$^{\mp}$} 
     \\
    \midrule
    Power    &  &  &  \\
\ \ \ \ \ \ \ \ One      &   16,4 pct.\sym{**}             & 19,5 pct.    \\ 
\ \ \ \ \ \ \ \ Two      &   16,8 pct.\sym{***}               & 15,0 pct.    \\ 
\ \ \ \ \ \ \ \ Three      &   19,2 pct.           & 17,8 pct.    \\ 
\ \ \ \ \ \ \ \ Four     &   16,6 pct.             & 16,7 pct.    \\ 
\ \ \ \ \ \ \ \ Five      &   16,4 pct.             & 15,3 pct.    \\ 
\ \ \ \ \ \ \ \ Six     &   14,7 pct.             & 15,7 pct.    \\ 

    \bottomrule
    \end{tabular*}
    \end{threeparttable}
    \end{table}
  • 1
    The \toprule stops also (above the column with 10) – user31729 Aug 7 '15 at 20:29
  • 1
    Look at your screen shot: The (thicker) \toprule stops shortly before the 10 - column – user31729 Aug 7 '15 at 20:33
  • 6
    The content is much larger than \textwidth. – Ulrike Fischer Aug 7 '15 at 20:34
  • 1
    @A.F. Either a smaller font or you have to get rid off those multiple *** stuff (whatever that means there), perhaps you can reduce the column widths significantly. Or redesign your table – user31729 Aug 7 '15 at 20:38
  • 3
    you can't have \begin{landscape} before \begin{document} If you want the entire document landscape remove the landscape environment and use the landscape documentclass option. – David Carlisle Aug 8 '15 at 6:23
5

You had to replace \textwidth with \linewidth: \textwidth is the global textwidth (in portrait mode), while \linewidth is the current line width – which means \textheight when you're in a landscape environment. I took the opportunity to simplify your code, removing all this plethora of \multicolumns.

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{layout}
\usepackage[protrusion=true,expansion=true]{microtype}

% Different usepackages
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage{icomma}
\usepackage{setspace}
\setstretch{1.10}
\usepackage{siunitx,booktabs}
\usepackage{graphicx}

% Page margins
\usepackage[hmargin=3.5cm, vmargin=3.4cm]{geometry}%

% Tabular
\usepackage{threeparttable}   
\newcommand\sym[1]{\textsuperscript{\rlap{\,#1}}}
% \includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}

\usepackage{float}

% Rotate
\usepackage{pdflscape}

\begin{document}
\begin{landscape}
  \mbox{}\vfill
  \begin{table}[H]
    \begin{threeparttable}
      \renewcommand\arraystretch{1.1}
      \medskip
      \renewcommand\tabcolsep{1pt} % Set this to some very small value ...
      \begin{tabular*}{\linewidth}{ @{}l
          @{\extracolsep{\fill}} % and let LaTeX provide the necessary "fill" amount
          *{12}{S[table-format=1.2, table-space-text-pre=(, table-space-text-post=)]} @{\hphantom{\textsuperscript{***}}}}
        \toprule
        \emph{?} & \multicolumn{4}{c}{Room1} & \multicolumn{4}{c}{Room2} & \multicolumn{4}{c}{Room3} \\
        \cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
        & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} & {(8)} & {(9)} & {(10)} & {(11)} & {(12)} \\
        \emph{Dep.\ var.} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} \\
        \midrule
        \emph{Undep.\ var.}\\
        Electricity & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} \\
        & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} \\
        Ohm & 0,00{\sym{***}} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} \\
        & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} \\
        \cmidrule{1-1}
        R\textsuperscript{2} & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 \\
        N & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} \\
        \bottomrule
      \end{tabular*}
    \end{threeparttable}
  \end{table}
  \vfill\newpage
\end{landscape}

\end{document} 

enter image description here

Space between two and three stars. enter image description here

Added New code for the second table: I redefined the sym command sio that it doesn't change the alignment of the cells, and I simplified the code (only three columns):

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{layout}
\usepackage[protrusion=true,expansion=true]{microtype}

% Different usepackages
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage{icomma}
\usepackage{setspace}
\setstretch{1.10}
\usepackage{siunitx,booktabs}
\usepackage{graphicx}

% Page margins
\usepackage[hmargin=3.5cm, vmargin=3.4cm]{geometry}%

% Tabular
\usepackage{threeparttable}
\newcommand\sym[1]{\textsuperscript{\rlap{\,#1}}}
% \includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}

\usepackage{float}

\begin{document}

\begin{table}[H]
  \centering
  \begin{threeparttable}
    \renewcommand\arraystretch{1.1}
    \medskip
    \begin{tabular*}{0.82\textwidth}{
        @{\extracolsep{\fill}}
        >{\hphantom{Power}}l
        S[table-format=2.1]
        S[table-format=2.1]
      }
      \toprule
      & {Randomized$^{\pm}$} & {Electricity$^{\mp}$}
      \\
      \midrule
      \llap{Power} & {pct.}& {pct.}\\
      One & 16,4 & 19,5 \sym{***} \\
      Two & 16,8 & 15,0 \\
      Three & 19,2 & 17,8\sym{**} \\
      Four & 16,6 & 16,7 \\
      Five & 16,4 & 15,3 \\
      Six & 14,7 & 15,7 \\
      \bottomrule
    \end{tabular*}
  \end{threeparttable}
\end{table}

\end{document} 

enter image description here

  • 1
    The \hphantom are here because I did not take the stars into account for the formatting of the S columns (I had to, in order to have a correct placement of ) in the row below). So in the last column, the stars go into the margin if we use @{}. . So you have to use @{\hphantom{\textsuperscript{max number of stars in the last column}}}. – Bernard Aug 9 '15 at 15:56
  • 1
    Second question: I would use {--} (I mean an endash, between brackets, to have it centred in its column. – Bernard Aug 9 '15 at 15:58
  • 1
    \sisetup{output-decimal-marker=,}, or use the argument of \sisetup as an optional argument to the S qualifier in the table. For the problem of the spacing with the spars, I'll try to find what happens. I note also the right parenthesis with 0.19 has a larger spacing. If there are only a few such problems, you may in the meantime play with \! or \,, or even \mkernxmu. – Bernard Aug 9 '15 at 16:43
  • 1
    Also, for the parenthesis, you should in tables use tabular numbers, since Minion Pro has the 4 kinds of numbers. – Bernard Aug 9 '15 at 16:45
  • 1
    Let us continue this discussion in chat. – Bernard Aug 9 '15 at 17:05

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.