[Tex/LaTex] What does mean the code in this table

longtabletablestabularx

After see the Andrew Swann solution to my previous question: How to fit this table in a page? I tried to fit it to another table:

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish,mexico]{babel}
\usepackage[T1]{fontenc}
\usepackage{booktabs,longtable}
\usepackage{array}

\begin{document}

{\small\setlength\tabcolsep{5pt}
\begin{tabularx}{\linewidth}{ll*{2}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}}
\caption{Temario de actividades Secundaria} \\
\toprule
\textsc{Horario} & \textsc{Ejercicio} & \textsc{Grado de riesgo} & \textsc{Material}\\
\addlinespace[0.5ex]
\toprule
\addlinespace[2ex]
\endfirsthead
\multicolumn{4}{c}{\textsc{\tablename~\thetable}\enspace (continuación)}\\
\addlinespace[2ex]
\toprule
\textsc{Horario} & \textsc{Ejercicio} & \textsc{Grado de riesgo} & \textsc{Material}\\
\addlinespace[0.5ex]
\toprule
\endhead
\midrule
\multicolumn{4}{r}{Continúa}
\endfoot
\bottomrule
\endlastfoot
    {\normalsize Día 1} & Bienvenida Encuadre Tema:Acuerdos de convivencia Ejercicios psicométricos & 1 & Pelota de esponja \emph{Brincón} Ejercicios psicométricos. Guía Eureka (Ver Anexo)\\
 \addlinespace
     {\normalsize Día 2} & Ejercicios psicométricos & 0 & Ejercicios psicométricos. Guía Eureka\\
\addlinespace
    {\normalsize Día 3} & Ejercicios psicométricos & 0 & Ejercicios psicométricos\\
\addlinespace
    {\normalsize Día 4} & Examen simulacro de ejercicios psicométricos en equipo & 0 & Ejercicios psicométricos. Guía verde actualizada 2000 (Ver Anexo).\\
\addlinespace
    {\normalsize Día 5} & EXAMEN DE CONOCIMIENTOS GENERALES & & \\
\end{tabularx}
}
\end{document}

Well, that's the table I need to do, but I'm not sure how to do it well. My first doubt is about the column statement, from my previous question and other solutions I saw I adapted this:

\begin{tabularx}{\linewidth}{ll*{3}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}}

As I need 5 columns, I understand that the table has 3 left aligned columns, later another not justified (RaggedRight) and a final X column, am I right? But I'm not sure about it. The code in ll*{3}{>{\RaggedRight\arraybackslash\hspace{0pt}}X} is hard to understand for me, could someone explain me?


Update

After the comments and the answer I made few corrections in the table, I saw that a a column had not sense. But the layout of the table is awful. How can I fix it? Is there a way to list or separate the text in a cell if I need a list and not a paragraph?

Best Answer

ll*{3}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}

is

ll

two columns of single line left aligned entries, then

 *{3}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}

three copies of >{\RaggedRight\arraybackslash\hspace{0pt}}X

each of these is basically an X column which is p{...} for an automatically calculated width.

The tokens in the >{...} are applied to the start of each cell. In this case that is

\RaggedRight\arraybackslash\hspace{0pt}

\RaggedRight is an improved version of \raggedright from the ragged2e package.

\arraybackslash is defined in tabularx it redefines \\ to end the table row (which is its normal definitions in tabular, but \ragedright, \RaggedRight etc redefine it locally to make a ragged text line end, which is not wanted here.

Starting a paragraph with \hspace{0pt} is an old trick to put a space before the first word which allows TeX to hyphenate the first word in the paragraph. (TeX's hyphenation algorithm otherwise doesn't consider the first word, which is probably a bug really but TeX is frozen and isn't going to change that behaviour.

Related Question