3

How to change 2021-2022 to red color in the table

\documentclass{article}
\usepackage{tabularx} 

\begin{document}
    \begin{tabular}{cl}
    Year 2023-2024 & Very long very long text Very long very long text Very long very long text  \\
    Year 2022-2023 & Very long very long text Very long very long text Very long very long text \\
    Year 2021-2022 & Very long very long text Very long very long text Very long   \\
    Year 2020-2021 & Very long very long text Very long very long text Very long very long text  \\
    Year 2019-2020 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
    Year 2018-2019 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
    \end{tabular}
\end{document}
5

You can use the \textcolor command in order to color the text. If you want to color the background of a cell, you can use the \cellcolor command as shown in the following MWE. I have also replaced the tabular by a tabularx environment (since you already loaded the tabularx package) in order to get rid of the overfull box:

enter image description here

\documentclass{article}
\usepackage[table]{xcolor} % <--- table option only needed if you want to color the background of a cell
\usepackage{tabularx} 

\begin{document}
    \begin{tabularx}{\linewidth}{cX}
    Year 2023-2024 & Very long very long text Very long very long text Very long very long text  \\
    Year 2022-2023 & Very long very long text Very long very long text Very long very long text \\
    \textcolor{red}{Year 2021-2022} & Very long very long text Very long very long text Very long   \\
    \cellcolor{red} Year 2020-2021 & Very long very long text Very long very long text Very long very long text  \\
    Year 2019-2020 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
    Year 2018-2019 & Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text Very long very long text  \\
    \end{tabularx}
\end{document}

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.