Well fit tables in LaTeX is hard for me, and I don't know if there is a manual with good practices about it. I need to create a table with S columns contending numbers, but the header of those columns are very long and I can't find a way to fit it into the page with the tricks learned here.
My MWE could be something like:
\documentclass[fontsize=11pt,paper=letter,headings=small,bibliography=totoc,DIV=9,headsepline=true]{scrartcl}
\usepackage[utf8]{inputenx}
\usepackage[TS1,T1]{fontenc}
\usepackage{textcomp}
\usepackage[spanish,mexico]{babel}
\usepackage[intlimits]{amsmath}
\usepackage{xspace}
\usepackage{xkeyval}
\usepackage{array,multirow,tabularx,ragged2e,booktabs}
%\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
%\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage[per-mode=symbol]{siunitx}
\sisetup{
output-decimal-marker = {,},
range-units = brackets,
list-final-separator = { \translate{and} },
list-pair-separator = { \translate{and} },
range-phrase = { \translate{to (numerical range)} },
}
\ExplSyntaxOn
\providetranslation [ to = Spanish ]
{ to~(numerical~range) } { a }%substitute the right word here
\ExplSyntaxOff
\begin{document}
\begin{table}[htb]
\caption{Capacidad de generación eléctrica en México}
\label{tab:CGE}
\centering
\begin{tabularx}{\textwidth}{@{} l S S[table-format=6.2] S[table-format=3.2]@{}}
\toprule
& \textbf{Permisos de la CRE} & \textbf{Capacidad de generación de energía} [\si{\giga\watt\hour}] & \textbf{Porcentaje}\\
\midrule
% Pública
\textbf{Energía de generación propia} & & \textbf{169,900.00} & \textbf{42.25} \\
\midrule
\textbf{Pemex} & & & \\
\textbf{Autoabastecimiento} & 31 & 2526.40 & 0.61 \\
\textbf{Cogeneración} & 18 & 7049.04 & 1.75 \\
\textbf{Subtotal} & & 9575.44 & 2.38 \\
% Privada
\midrule
\textbf{Autoabastecimiento} & 486 & 67145.80 & 16.70 \\
\textbf{Cogeneración} & 109 & 18153.66 & 4.51 \\
\textbf{Producción independiente} & 30 & 105634.80 & 26.27 \\
\textbf{Exportación} & 8 & 13295.60 & 3.31 \\
\textbf{Importación} & 44 & 2061.30 & 0.51 \\
\textbf{Pequeña producción} & 178 & 12212.60 & 3.04 \\
\textbf{Usos Propios Continuos} & 36 & 1523.50 & 0.38 \\
\textbf{Pemex-Cogeneración} & 1 & 2628.00 & 0.65 \\
\textbf{Subtotal} & 844 & 222655.26 & 55.37 \\
\textbf{Total CRE} & 892 & 232230.70 & 57.75 \\
\midrule
\textbf{Total} & 892 & 402130.14 & 100 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
As you can see my first issue is to fit the table inside the page. The second one is put in boldface the units in the title row. A third issue is to add a column in the left side of the table to specify the public and private generation, bit I think that could be easy to solve after the first one.
Sorry if this is a duplicate question, but I didn't found an answer in the questions I was reading before to ask.



>{\bfseries} lin the declaration of columns, and avoid using\textbf{..}in each cell of the first column. – Manuel Jun 06 '15 at 08:29