The problem is that \cprotEnv
is thought for particular environments such as align
that don't accept verbatim in their body. If your schemes are always like the example, with two "handed lines", it's easier to define a command rather than an environment:
\newcommand{\CDROM}[3]
{\begin{tabular}{| m{0.5in} m{0.3in} m{5in} |}
\hline
\includegraphics[width=0.5in]{CD-ROM.pdf} && #1 \\
& \includegraphics[width=0.3in]{Hand.pdf} &
We used the free compiler #2. \\
& \includegraphics[width=0.3in]{Hand.pdf} & #3\\ \hline \end{tabular}}
and then use it as
\cprotect[mmm]\CDROM{\verb"\SampleCodes\C++\GetPageSize"}{Open Watcom}
{The page size for this system is 4096 bytes.}
A way that frees you from \cprotect
is
\newcommand{\CDROM}{\begingroup\catcode`\#=12 \xCDROM}
\newcommand{\xCDROM}[3]
{\begin{tabular}{| m{0.5in} m{0.3in} m{5in} |}
\hline
\includegraphics[width=0.5in]{CD-ROM.pdf} &&
\ttfamily\catcode`\\=12 \catcode`\ =9
\scantokens{#1} \\
& \includegraphics[width=0.3in]{Hand.pdf} &
We used the free compiler #2. \\
& \includegraphics[width=0.3in]{Hand.pdf} & #3\\ \hline \end{tabular}\endgroup}
and now
\CDROM{\SampleCodes\C++\GetPageSize}{Open Watcom}
{The page size for this system is 4096 bytes.}
\CDROM{\SampleCodes\C#\GetPageSize}{}{}
work without \verb
. This, however, assumes that you don't need spaces in the "verbatim" first argument.
By splitting the command into two parts we can ensure that the #
character is not doubled as it would happen if we added \catcode`\#=12
along with the other settings.
In this answer, I have given a solution to the problem, but also an alternate approach, which in my opinion, would not only look better, but also be more customizable and maintanable. The alternate approach is located below the solution to the problem
Problematic table
The error occurs because the \catcode`_=13
is set within the longtable
, so that it's scope would be only effective for a single row. I've moved this code outside the longtable
and added curly braces around it, and the longtable
to limit the scope of this.
When you use \multicolumn
and set add lots of text inside, the content will be treated as a single cell, so longtable
is not able to the content, as it cannot break a cell, only rows.
Further suggestions
- Use
\endhead
and friends from longtable
-package to have the same headers and footers on every page.
- When printing variables, such as
consumer_price_index
, set them in monospace font, using \ttfamily
or \texttt
.
- Make hyphenations for
_
possible with the underscore
-package. There are multiple alternatives.
- Create some more space between lines to improve the readability, especially with these long variables.
- Make sure you use code you only know the effect of. For your column specifiers, you seem to be doing something unnecessary with
\let\newline\\\arraybackslash
. Who gave you that code?
- When commenting your code, make sure you don't write something that is plain wrong, or at least very redundant.
tabulary
is meant for tables, yes, but what does it actually do? You don't need it for tables, and the comment would just confuse you, and everybody reading your code.
Output
Here is a comparison of 3,4 and 5-columns for your content. it can easilty be changed with changin before=\begin{multicols}{3}
Code
\documentclass[12pt]{report}
\usepackage{underscore}% To hyphenate \_
\usepackage{array}
\usepackage{calc}
\usepackage{ltablex}
\usepackage[font={small}]{caption}
\usepackage{booktabs}
\usepackage{showframe}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash\hspace{0pt}}m{#1}}%This is a wrapper to make everything a certain width -left aligned columns with stuff at the top. lines in cells
\newcommand{\cf}[1]{%
\multicolumn{1}{c}{\bfseries#1}
}
\begin{document}
{% start a group to limit scope
\catcode`_=13 % Make _ "active";
\def_{\textunderscore\hspace{0pt}} % "meaning" of "_"
% \scriptsize
\renewcommand{\arraystretch}{1.4}% some exstra space between lines, for clarity
\begin{longtable}{*{3}{>{\ttfamily}L{\textwidth/3-4\tabcolsep}|}}
\caption{List of Open and Closed Evaluation Properties}
\label{table:openclosed}\\
\toprule
\cf{Open Properties} & \cf{Closed Properties} &
\cf{Sentence Label Properties} \\
\midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\cf{Open Properties} & \cf{Closed Properties} &
\cf{Sentence Label Properties} \\
\midrule
\endhead
\bottomrule
\endfoot
consumer_price_index & consumer_price_index & agriculture_as_percent_of_gdp\\
cpi_inflation_rate & cpi_inflation_rate & arithmetic_population_density\\
diesel_price_liter & diesel_price_liter & automobiles_per_capita\\
fertility_rate & fertility_rate & brain_drain_percent\\
foreign_direct_investment_net_inflows & gdp_nominal & broadband_penetration_rate\\
gdp_growth_rate & gdp_nominal_per_capita & child_labor_percent\\
gdp_nominal & gni_in_ppp_dollars & co2_emissions_commercial\\
gdp_nominal_per_capita & gni_per_capita_in_ppp_dollars & co2_emissions_industrial\\
gdp_real & health_expenditure_as_percent_of_gdp & co2_emissions_mobile\\
gni_in_ppp_dollars & internet_users_percent_population & co2_emissions_per_capita\\
gni_per_capita_in_ppp_dollars & labor_participation_rate & co2_emissions_residential\\
health_expenditure_as_perce\nt_of_gdp & life_expectancy & co2_emissions_total\\
internet_users_percent_population & population & consumer_price_index\\
labor_participation_rate & population_growth_rate & cpi_inflation_rate\\
life_expectancy & prevalence_of_undernourisment & debt_service_as_percent_of_trade_volume\\
merchandise_trade_percent_of_gdp & renewable_freshwater_per_capita & deposit_interest_rate\\
net_migration & & diesel_price_liter\\
population & & electricity_consumption_per_capita\\
population_growth_rate & & electricity_production\\
prevalence_of_undernourisment & & energy_use_per_capita\\
renewable_freshwater_per_capita & & exports_as_percent_of_gdp\\
size_of_armed_forces & & external_debt_stock\\
time_required_to_start_a_business & & fertility_rate\\
trade_balance_as_percent_of_gdp & & foreign_direct_investment_net_inflows\\
& & gas_price_liter\\
& & gdp_deflator_change\\
& & gdp_growth_rate\\
& & gdp_nominal\\
& & gdp_nominal_per_capita\\
& & gdp_real\\
& & global_competitiveness_index\\
& & gni_in_ppp_dollars\\
& & gni_per_capita_in_ppp_dollars\\
& & government_debt_percent_gdp\\
& & greenhouse_gas_emission\\
& & greenhouse_gas_emission_intensity\\
& & greenhouse_gas_emissions_per_capita\\
& & gross_capital_formation_as_percent_of_gdp\\
& & gross_savings_as_percent_of_gdp\\
& & health_expenditure_as_percent_of_gdp\\
& & high_tech_as_percent_of_manufactured_exports\\
& & hiv_prevalence_rate\\
& & household_consumption_expenditure_as_percent_of_gdp \\
& & imports_as_percent_of_gdp\\
& & industry_as_percent_of_gdp\\
& & internet_users\\
& & internet_users_percent_population\\
& & labor_participation_rate\\
& & lending_interest_rate\\
& & life_expectancy\\
& & literacy_rate\\
& & long_term_unemployment_rate\\
& & market_cap_of_listed_companies_as_percent_of_gdp\\
& & merchandise_trade_percent_of_gdp\\
& & military_expenditure_percent_gdp\\
& & minimum_wage\\
& & natural_gas_production\\
& & net_migration\\
& & net_workers_remittances\\
& & official_development_assistance\\
& & oil_production\\
& & part_time_employment_percent\\
& & population\\
& & population_growth_rate\\
& & poverty_rate_2dollars_per_day\\
& & prevalence_of_undernourisment\\
& & renewable_freshwater_per_capita\\
& & services_as_percent_of_gdp\\
& & size_of_armed_forces\\
& & smoking_prevalence_rate\\
& & tax_revenue_percent_of_gdp\\
& & time_required_to_start_a_business\\
& & trade_balance_as_percent_of_gdp\\
& & unemployment_rate
\end{longtable}
}% end scope
\end{document}
Alternate approach
As I interpret, you simply want a list of some variables, or properties. Therefore, a list would be more suited, than a tabular, which is more intented to compare and differentiate information, not list them. Therefore I suggest a modifieditemize
-environment called propertyList
. It should be highly modifieable. You can easaly adjust how many columns you want, spacing, font and such, with the enumitem
-package.
Output
Code
\documentclass{article}
\usepackage{multicol}
\usepackage{underscore}
\usepackage{enumitem}
\usepackage[margin=0.5cm]{geometry}
\newlist{propertyList}{itemize}{1}
\setlist[propertyList]{
label=\textbullet,
noitemsep,
leftmargin=10pt,
font=\rmfamily,
before=\begin{multicols}{3}%
\ttfamily,
after=\end{multicols}
}
\begin{document}
\section*{List of Open and Closed Evaluation Properties}
\subsection*{Open Properties}
\begin{propertyList}
\item cpi_inflation_rate
\item diesel_price_liter
\item fertility_rate
\item foreign_direct_investment_net_inflows
\item gdp_growth_rate
\item gdp_nominal
\item gdp_nominal_per_capita
\item gdp_real
\item gni_in_ppp_dollars
\item gni_per_capita_in_ppp_dollars
\item health_expenditure_as_percent_of_gdp
\item internet_users_percent_population
\item labor_participation_rate
\item life_expectancy
\item merchandise_trade_percent_of_gdp
\item net_migration
\item population
\item population_growth_rate
\item prevalence_of_undernourisment
\item renewable_freshwater_per_capita
\item size_of_armed_forces
\item time_required_to_start_a_business
\item trade_balance_as_percent_of_gdp
\end{propertyList}
\subsection*{Closed Properties}
\begin{propertyList}
\item cpi_inflation_rate
\item diesel_price_liter
\item fertility_rate
\item gdp_nominal
\item gdp_nominal_per_capita
\item gni_in_ppp_dollars
\item gni_per_capita_in_ppp_dollars
\item health_expenditure_as_percent_of_gdp
\item internet_users_percent_population
\item labor_participation_rate
\item life_expectancy
\item population
\item population_growth_rate
\item prevalence_of_undernourisment
\item renewable_freshwater_per_capita
\end{propertyList}
\subsection*{Sentence Label Properties}
\begin{propertyList}
\item agriculture_as_percent_of_gdp
\item arithmetic_population_density
\item automobiles_per_capita
\item brain_drain_percent
\item broadband_penetration_rate
\item child_labor_percent
\item co2_emissions_commercial
\item co2_emissions_industrial
\item co2_emissions_mobile
\item co2_emissions_per_capita
\item co2_emissions_residential
\item co2_emissions_total
\item consumer_price_index
\item cpi_inflation_rate
\item debt_service_as_percent_of_trade_volume
\item deposit_interest_rate
\item diesel_price_liter
\item electricity_consumption_per_capita
\item electricity_production
\item energy_use_per_capita
\item exports_as_percent_of_gdp
\item external_debt_stock
\item fertility_rate
\item foreign_direct_investment_net_inflows
\item gas_price_liter
\item gdp_deflator_change
\item gdp_growth_rate
\item gdp_nominal
\item gdp_nominal_per_capita
\item gdp_real
\item global_competitiveness_index
\item gni_in_ppp_dollars
\item gni_per_capita_in_ppp_dollars
\item government_debt_percent_gdp
\item greenhouse_gas_emission
\item greenhouse_gas_emission_intensity
\item greenhouse_gas_emissions_per_capita
\item gross_capital_formation_as_percent_of_gdp
\item gross_savings_as_percent_of_gdp
\item health_expenditure_as_percent_of_gdp
\item high_tech_as_percent_of_manufactured_exports
\item hiv_prevalence_rate
\item household_consumption_expenditure_as_percent_of_gdp
\item imports_as_percent_of_gdp
\item industry_as_percent_of_gdp
\item internet_users
\item internet_users_percent_population
\item labor_participation_rate
\item lending_interest_rate
\item life_expectancy
\item literacy_rate
\item long_term_unemployment_rate
\item market_cap_of_listed_companies_as_percent_of_gdp
\item merchandise_trade_percent_of_gdp
\item military_expenditure_percent_gdp
\item minimum_wage
\item natural_gas_production
\item net_migration
\item net_workers_remittances
\item official_development_assistance
\item oil_production
\item part_time_employment_percent
\item population
\item population_growth_rate
\item poverty_rate_2dollars_per_day
\item prevalence_of_undernourisment
\item renewable_freshwater_per_capita
\item services_as_percent_of_gdp
\item size_of_armed_forces
\item smoking_prevalence_rate
\item tax_revenue_percent_of_gdp
\item time_required_to_start_a_business
\item trade_balance_as_percent_of_gdp
\item unemployment_rate
\end{propertyList}
\end{document}
Best Answer
As you have already noted, you have misspelled
tabular
. In addition, the column specifiers are mentioned asC
rather thanc
. Correcting both, your code compiles fine to yield the table shown.Is it what you are expecting?