I have lots of text in multiple columns in tables which contains items with underscores. However, these do not wrap around a fixed column width, so I get:
Here is my code:
\documentclass[12pt]{report}
\usepackage{array,ltablex, makecell}%
\renewcommand\theadfont{\normalsize\bfseries}
% \renewcommand*\descriptionlabel[1]{\hspace\leftmargin$#1$}%This is for descriptions to appear on the LHS with an indent
\newenvironment{conditions}
{\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}}
{\end{tabular}\par\vspace{\belowdisplayskip}}%This is for descriptions of equations
\usepackage[]{multirow}
\usepackage[autostyle]{csquotes}% This is for quotes
\usepackage{tabulary}% This is for tables
\usepackage{ragged2e}
\usepackage{longtable,array,ragged2e}% This is formatting for long tables
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{graphicx}% This is for images
\usepackage{booktabs,dcolumn,caption}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}%This is for precision tables per property
\newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type
\renewcommand{\ast}{{}^{\textstyle *}} % for raised "asterisks"
\begin{document}
\begin{table}[!htbp]
\centering
\caption{List of Open and Closed Evaluation Properties}
\label{table:openclosed}
\ra{1.0}%This stretches the contents of cells
\begin{tabular}{|C{4cm}|C{4cm}|C{4cm}|}
\hline
\textbf{Open Properties} & \textbf{Closed Properties} &
\textbf{Sentence Label Properties} \\
\hline
\begin{tabular}{@{}l@{}}
\verb|gni_per_capita_in_ppp_dollars|\\
\verb|health_expenditure_as_percent_of_gdp|\\
\end{tabular}
&
\begin{tabular}{@{}l@{}}
\verb|gni_in_ppp_dollars|\\
\verb|gni_per_capita_in_ppp_dollars|\\
\verb|health_expenditure_as_percent_of_gdp|\\
\verb|internet_users_percent_population|\\
\verb|labor_participation_rate|\\
\verb|life_expectancy|\\
\verb|merchandise_trade_percent_of_gdp|\\
\verb|net_migration|\\
\verb|population|\\
\verb|population_growth_rate|\\
\verb|prevalence_of_undernourisment|\\
\verb|renewable_freshwater_per_capita|\\
\verb|size_of_armed_forces|\\
\end{tabular}
&
\begin{tabular}{@{}l@{}}
\verb|consumer_price_index|\\
\verb|cpi_inflation_rate|\\
\verb|diesel_price_liter|\\
\end{tabular}\\
\hline
\end{tabular}
\end{table}
\end{document}
How can I get these values to wrap around and fit the cells in new lines if they go beyond the allocated width? In addition, if any column contains less rows than the longest column in its row (e.g. column 2 has less items than column 1), I would like the text to start at the top instead of the middle. Just adding [t]
to the inner tabulars didn't seem to work per this: Top alignment of cell content in tabularx.