1

enter image description here

My table is to wide. Anyone know how to make it fit the page?

This is my code:


    \begin{table}[]
\scalebox{0.8}{


\begin{tabular}{llll}
\rowcolor[HTML]{9B9B9B} 
{\color[HTML]{000000} \textbf{Activity}} & {\color[HTML]{000000} \textbf{Aspects}} & {\color[HTML]{000000} \textbf{Impacts}} & {\color[HTML]{000000} \textbf{Level of influence}} \\
\rowcolor[HTML]{C0C0C0} 
Anode production &  &  &  \\ \hline
Energy and anode baking & CO$_2$ emissions & Global warming & Global \\ \hline
Anode butts & Emission of SO$_2$, NO$_x$ and fluorides & Negative impact on air, soil and water & Regional, local \\ \hline
 & Emissions of dust & Poor air quality, human health & Local \\ \hline
 & PAH emissions & Human health, accumulates in marine species (e.g. mussels) & Local \\ \hline
Use of cooling water & Emissons to water & Negative impact on the marine environment & Local \\ \hline
\rowcolor[HTML]{C0C0C0} 
Electrolysis, aluminum smelting &  &  &  \\ \hline
Energy and anode consumption & CO$_2$ emissions & Global warming & Global \\ \hline
Anode effects & PFC emissions & Global warming & Global \\ \hline
Anode consumption & SO$_2$ emissions & Environmental acidification, health problems & Regional, local \\ \hline
 & NO$_x$ emissions, fluorides & respiratory diseases,  acid rain & Regional, local \\ \hline
 & Carbon monoxide & ozone precursors & Local \\ \hline
 & SPL &  & Local \\ \hline
 & Metal compounds & Toxic for environment & Local \\ \hline
\rowcolor[HTML]{C0C0C0} 
Casting and remelting &  &  &  \\
Energy consumption & CO$_2$ emissions & Global warming & Global \\ \hline
Fuel consumption & SO$_2$ emissions & Environmental acidification, health problems & Regional, local \\ \hline
Burning & NO$_x$ emissions & respiratory diseases,  acid rain & Regional, local \\ \hline
 & Volatile organic compounds & ozone precursors & Local \\ \hline
Skimming & Emission of dross & Toxic for environment & Local \\ \hline
\end{tabular}}
\end{table}

3
3

In portrait orientation, with tabularx and cellspace:

\documentclass{article}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs, makecell, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash\hspace{0pt}%
                    \linespread{0.84}\selectfont}X}
\usepackage[column=O]{cellspace}
    \setlength\cellspacetoplimit{2pt}
    \setlength\cellspacebottomlimit{2pt}
    \addparagraphcolumntypes{L}

\usepackage{mhchem}

\begin{document}
    \begin{table}
    \setlength\tabcolsep{3pt}
    \small
\begin{tabularx}{\linewidth}{@{} O{L} >{\hsize=0.8\hsize}O{L}
                                      >{\hsize=1.2\hsize}O{L} 
                                l
                             @{}}
    \toprule
\textbf{Activity}
    &   \textbf{Aspects}
        &   \textbf{Impacts}
            &   \textbf{\makecell[l]{Level of\\ influence}}    \\
    \specialrule{\lightrulewidth}{\abovetopsep}{0pt}
    \rowcolor{gray!20}
\multicolumn{4}{Ol}{\textbf{Anode production}}   \\
Energy and anode baking
    &   \ce{CO2} emissions
        &   Global warming
            &   Global                              \\
Anode butts
    &   Emission of \ce{SO2}, \ce{NO_x} and fluorides
        &   Negative impact on air, soil and water
            &   Regional, local                     \\
    &   Emissions of dust
        & Poor air quality, human health
            & Local                                 \\
    & PAH emissions
        & Human health, accumulates in marine species (e.g. mussels)
            & Local                                 \\
Use of cooling water
    &   Emissions to water
        &   Negative impact on the marine environment
            &   Local                               \\
    \specialrule{\lightrulewidth}{\abovetopsep}{0pt}
    \rowcolor{gray!30}
\multicolumn{4}{Ol}{\textbf{Electrolysis, aluminum smelting}}\\
Energy and anode consumption
    &   \ce{CO2} emissions
        &   Global warming
            &   Global                              \\
Anode effects
    &   PFC emissions
        &   Global warming
            &   Global                              \\
Anode consumption
    &   \ce{CO2} emissions
        &   Environmental acidification, health problems
            &   Regional, local                     \\
    &   \ce{NO_x} emissions, fluorides
        &   respiratory diseases, acid rain
            &   Regional, local                     \\
    &   Carbon monoxide
        &   ozone precursors
            &   Local                               \\
    & SPL
        &
            &   Local                               \\
    &   Metal compounds
        &   Toxic for environment
            &   Local                               \\
    \specialrule{\lightrulewidth}{\abovetopsep}{0pt}
    \rowcolor{gray!30}
\multicolumn{4}{Ol}{\textbf{Casting and remelting}}\\
Energy consumption
    &   \ce{CO2} emissions
        &   Global warming
            &   Global                          \\
Fuel consumption
    &   \ce{SO2} emissions
            & Environmental acidification, health problems
            & Regional, local                   \\
Burning
    &   \ce{NO_x} emissions
        &   respiratory diseases, acid rain
            &   Regional, local                 \\
    &   Volatile organic compounds
        &   ozone precursors 
            & Local                             \\
Skimming
    &   Emission of dross
        &   Toxic for environment
            &   Local                           \\
    \bottomrule
\end{tabularx}
    \end{table}
\end{document}   

enter image description here

Addendum. Regarding your comment about width of columns:

Columns L widths are set by >{\hsize=<ratio>. \hsize}. If <ratio> is 1 At this sum of all <ratio> had to be equal to number od L columns in table. In your case it should be 3 (three):

> O{L}                   % <--- ratio is 1
>{\hsize=0.8\hsize}O{L}  % <--- ratio is 0.8
>{\hsize=1.2\hsize}O{L}  % <--- ratio is 1.2
                         -------------------       
                                   sum = 3

On this way you can change ratios beteen L columns in your table. For example, table is narrowed first column width:

\begin{tabularx}{\linewidth}{@{} 
                 >{\hsize=0.6\hsize}O{L} %  0.8
                                    O{L} %  1.0
                 >{\hsize=1.4\hsize}O{L} %  1.2
                                       l
                             @{}}

Using this table preamble in above MWE produce:

enter image description here

Addendum (2): If you like to have justified text in your columns, than don't use L column specifier but X. To preserve some features of L column definition also in in X column, you have to choices:

  • at each use of X add option >{\hspace{0pt}\linespread{0.84}\selectfont}
  • or defined new column type, for example Y, which consider above settings:
\newcolumntype{Y}{>{\hspace{0pt}\linespread{0.84}\selectfont}X}
% using this, "L" column can be now defined as
\newcolumntype{L}{>{\raggedright\arraybackslash}Y}

I believe, that now is time, that you make yourself more familiar with table settings. Basics about them you can find in enter link description here. Also helps experimenting with different column types in table.

12
  • Thank You, I really liked your layout. However, when I tried to copy-paste the code, it is not working properly. – Lisa Nov 3 '20 at 10:29
  • @Lisa, what not work? Provided MWE is tested and result of compilation is presented. So you are change something ... – Zarko Nov 3 '20 at 10:34
  • I found the problem, thanks for the nice table! – Lisa Nov 3 '20 at 11:08
  • @Lisa, nice to hear this. Now You have three worked solutions, so you can accept this one, which to your opinion on the best way solve your problem (by clicking on the check mark, which is at top left side of selected answer). – Zarko Nov 3 '20 at 12:31
  • 1
    @Lisa, see addendum to answer. – Zarko Nov 18 '20 at 16:13
2

Here's a solution that does away with the adjustbox approach and permits automatic line breaking in all four columns with the help of the tabularx package and its eponymous LaTeX environment.

enter image description here

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}[1]{>{\RaggedRight\hsize=#1\hsize%
         \hangafter=1\hangindent=1em}X}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{mhchem}
\begin{document}
\begin{table}
\setlength\extrarowheight{2pt}

\begin{tabularx}{\textwidth}{L{0.86}L{1.14}L{1.3}L{0.7}}

\rowcolor[HTML]{9B9B9B} 
\textbf{Activity} & \textbf{Aspects} & 
\textbf{Impacts}  & \textbf{Level of influence} \\
\rowcolor[HTML]{C0C0C0} 
\multicolumn{4}{l}{Anode production}  \\ 
Energy and anode baking & \ce{CO2} emissions & Global warming & Global \\ 
Anode butts & Emission of \ce{SO2}, \ce{NO_x} and fluorides & Negative impact on air, soil and water & Regional, local \\ 
 & Emissions of dust & Poor air quality, human health & Local \\ 
 & PAH emissions & Human health, accumulates in marine species (e.g. mussels) & Local \\ 
Use of cooling water & Emissons to water & Negative impact on the marine environment & Local \\ 
\rowcolor[HTML]{C0C0C0} 
\multicolumn{4}{l}{Electrolysis, aluminum smelting} \\ 
Energy and anode consumption & \ce{CO2} emissions & Global warming & Global \\ 
Anode effects & PFC emissions & Global warming & Global \\ 
Anode consumption & \ce{SO2} emissions & Environmental acidification, health problems & Regional, local \\ 
 & \ce{NO_x} emissions, fluorides & respiratory diseases,  acid rain & Regional, local \\ 
 & Carbon monoxide & ozone precursors & Local \\ 
 & SPL &  & Local \\ 
 & Metal compounds & Toxic for environment & Local \\ 
\rowcolor[HTML]{C0C0C0} 
\multicolumn{4}{l}{Casting and remelting}  \\
Energy consumption & \ce{CO2} emissions & Global warming & Global \\ 
Fuel consumption & \ce{SO2} emissions & Environmental acidification, health problems & Regional, local \\ 
Burning & \ce{NO_x} emissions & respiratory diseases,  acid rain & Regional, local \\ 
 & Volatile organic compounds & ozone precursors & Local \\ 
Skimming & Emission of dross & Toxic for environment & Local \\ 
\bottomrule
\end{tabularx}
\end{table}
\end{document}
0

IMHO, your table is way too wide for a normal page. As can be seen by the other answers, it's possible to fit it to the page but you end up with a lot of multiline text which is hard to read in a table as you get easily lost. I would thus suggest using the sidewaystable environment of the rotating package and have the table in landscape format in the document. This also makes it way more readable.

Moreover, I suggest using the mhchem package for your chemical formulas like SO2.

Last but not least, I allowed myself to reformat the table a bit to increase the readability of both the code and the resulting table.

\documentclass{article}

\usepackage{booktabs}
\usepackage{array}
\usepackage{multicol}
\usepackage{rotating}

\usepackage{mhchem}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

\begin{sidewaystable}
    \begin{tabular}{
            L{0.2\linewidth}
            L{0.2\linewidth}
            L{0.4\linewidth}
            L{0.2\linewidth}
        }
        \toprule
        
        \textbf{Activity} 
            & \textbf{Aspects} 
            & \textbf{Impacts} 
            & \textbf{Level of influence}\\
        
        \midrule
    
        \multicolumn{4}{l}{\textbf{Anode production}}\\
        Energy and anode baking 
            & \ce{CO2} emissions 
            & Global warming 
            & Global\\
    
        Anode butts 
            & Emission of \ce{SO2}, $\ce{NO_x}$ and fluorides 
            & Negative impact on air, soil and water 
            & Regional, local\\
     
            & Emissions of dust 
            & Poor air quality, human health & Local\\
    
            & PAH emissions 
            & Human health, accumulates in marine species (e.g. mussels) 
            & Local\\
    
        Use of cooling water 
            & Emissons to water 
            & Negative impact on the marine environment 
            & Local\\
        
        \midrule
        
        \multicolumn{4}{l}{\textbf{Electrolysis, aluminum smelting}}\\
        Energy and anode consumption 
            & \ce{CO2} emissions 
            & Global warming 
            & Global\\
            
        Anode effects 
            & PFC emissions 
            & Global warming 
            & Global\\
            
        Anode consumption 
            & \ce{CO2} emissions 
            & Environmental acidification, health problems 
            & Regional, local\\
            
            & $\ce{NO_x}$ emissions, fluorides 
            & respiratory diseases, acid rain 
            & Regional, local\\
            
            & Carbon monoxide 
            & ozone precursors 
            & Local\\
            
            & SPL 
            &  
            & Local\\
            
            & Metal compounds 
            & Toxic for environment 
            & Local\\
            
        \midrule
            
        \multicolumn{4}{l}{\textbf{Casting and remelting}}\\
        Energy consumption 
            & \ce{CO2} emissions 
            & Global warming 
            & Global\\
            
        Fuel consumption 
            & \ce{SO2} emissions 
            & Environmental acidification, health problems 
            & Regional, local\\
            
        Burning 
            & $\ce{NO_x}$ emissions 
            & respiratory diseases, acid rain 
            & Regional, local\\
            
            & Volatile organic compounds 
            & ozone precursors & Local\\
            
        Skimming 
            & Emission of dross 
            & Toxic for environment 
            & Local\\
        
        \bottomrule
    \end{tabular}
\end{sidewaystable}

\end{document}

table


PS: Please provide a minimal working example (MWE) document in the future.

3

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.