2

I have a problem with table generation.

This is the code I'm using:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{float}
\RequirePackage[a4paper, left=2.5cm, right=2.5cm, bottom=2.5cm, top=2.5cm]{geometry}
\usepackage[usenames, dvipsnames]{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{array,multirow,graphicx}
\definecolor{lightgray}{rgb}{0.95,0.95,0.95}
\RequirePackage{ragged2e}

\begin{document}

\renewcommand{\arraystretch}{1.6}
\newcolumntype{Y}{>{\hsize=.7\hsize\RaggedRight\arraybackslash}X}
\newcolumntype{a}{>{\columncolor{lightgray}}Y}
\newcolumntype{C}[1]{>{\columncolor{lightgray}}p{#1}}

\begin{table}[H]
    \caption{XXXXXXXXXXXXXXXXXXXXXXX}
    \begin{tabularx}{\textwidth}{C{5mm}@{}a*{3}{Y}@{}}
        %% table header
        \hline
        \rowcolor{lightgray}\multicolumn{2}{r@{}}{XXXXXX $\rightarrow$} & \multicolumn{3}{c@{}}{The content of the word} \\
        \rowcolor{lightgray}\multicolumn{2}{l@{}}{$\downarrow$ XXXXXX} & XXXXX & XXXXXX & XXXXX \\ \hline
        %% body of table
        &XXXXX & XXXXX & XXXX  & XXXXX \\
        &XXXXX
         & XXXXX
         & XXXXX \par XXXXXXXXXX
         & XXXX, \par XXXX,\par XXXX/XXXX,\par XXXXX,\par XXXXXX, etc. \par \\
        \multirow{-3}{12mm}{\rotatebox{90}{\parbox{\linewidth}{XXXXXXX}}} &XXXXXX XXXXX &  XXXXXXXX \par sequence
         & XXXXXX
         & XXXXXX, \par XXXXX, \par XXXXX \\     \hline
    \end{tabularx}
\end{table}

\end{document}

Table generates correctly and looks OK but a lot warnings like these are shown:

Overfull \hbox (18.35681pt too wide) in paragraph at lines 35--35
[]\OT1/cmr/m/n/10 XXXXXXX 
 []


Overfull \hbox (19.91693pt too wide) in paragraph at lines 35--35
[]|[]| 
 []


Underfull \hbox (badness 10000) in alignment at lines 35--35
[][][][][] 
 []

Thank you in advance.

3

you receive just warning ... they are caused by use of RaggedRight and no consistency in defining of the first column. try the following changed code of your table:

\documentclass{article}
\usepackage[a4paper, margin=2.5cm]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\definecolor{lightgray}{rgb}{0.95,0.95,0.95}
\usepackage{ragged2e}
\usepackage{multirow, tabularx}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\newcolumntype{a}{>{\columncolor{lightgray}}Y}
\newcolumntype{C}[1]{>{\columncolor{lightgray}}p{#1}}
\usepackage{graphicx}

\begin{document}    
\renewcommand{\arraystretch}{1.6}
\begin{table}[ht]
    \caption{XXXXXXXXXXXXXXXXXXXXXXX}
    \begin{tabularx}{\textwidth}{C{12mm} a*{3}{Y}}
        %% table header
    \hline
    \rowcolor{lightgray}
\multicolumn{2}{r}{XXXXXX $\rightarrow$} 
                &   \multicolumn{3}{c}{The content of the word} \\
    \rowcolor{lightgray}
\multicolumn{2}{l}{$\downarrow$ XXXXXX} 
                & XXXXX     & XXXXXX    & XXXXX                 \\ 
    \hline
        %% body of table
    & XXXXX     & XXXXX     & XXXX  & XXXXX                     \\
    & XXXXX     & XXXXX     & XXXXX XXXXXXXXXX
                                    & XXXX, XXXX, 
                                      XXXX/XXXX, 
                                      XXXXX, XXXXXX, etc.       \\
\multirow{-4}{=}{\rotatebox{90}{XXXXXXX}} 
    & XXXXXX XXXXX 
                &  XXXXXXXX sequence 
                            & XXXXXX
                                    & XXXXXX, XXXXX, XXXXX      \\     
         \hline
    \end{tabularx}
\end{table}
\end{document}

enter image description here

to my taste table isn't nice. i would use caption package for caption, omit coloring and use booktabs for horizontal lines.

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.