I am using the tabularx package and as per previous answer this should sort by problem of having a table where rows are too wide. My understanding was this will wrap the texts and it would fit in. But actually this is going beyond the page width.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{wrapfig}
\usepackage{multirow}
\usepackage{tabularx}% for 'tabularx' env. and 'X' col. type
\usepackage{lscape}
\usepackage{listings}
\usepackage{color}
\usepackage{xparse}
\usepackage{placeins}
\usepackage{caption}
\usepackage{enumitem}
\usepackage{booktabs} % for \toprule, \midrule etc macros
\usepackage{ragged2e} % for \RaggedRight macro
\title{examle}
\author{An example from Overleaf}
\begin{document}
\maketitle
\renewcommand{\arraystretch}{1.3}
\listoftables
%% create a derivative column type called 'L':
\newcolumntype{L}{>{\RaggedRight\hangafter=1\hangindent=1.5em}X}
\vspace{1cm}
% \newcolumntype{b}{X}
% \newcolumntype{s}{>{\hsize=.5\hsize}X}
\begin{table*}
\caption{example}
\label{tab:code-example}
\centering
% \begin{tabularx}{\textwidth}{XX}
\begin{tabularx}{1.0\textwidth}{XX}
\toprule % replaced all \hline commands with rules from the booktabs package
\upshape Representation of the code & Code \\
\midrule
Representation 1
& \verb|ID math . ID1 calculateSomethingAwesome ( LIT 100 , LIT 200, LIT 300 )| \\
Another representation name that can be very very long
& \verb|ID math . ID1 calculateSomethingAwesome ( LIT 100 , INTEGER 200, LIT 300 )| \\
Representation 3
& \verb|ID math . ID1 calculateSomethingAwesome ( FLOAT 100 , NUMERIC 200, LIT ID 300 )| \\
\bottomrule
\end{tabularx}
\end{table*}
\end{document}
\hline
must occur inside atabular
-like orarray
-like environment; did you maybe mean to run\hrule
? Second, the use of\verb|...|
in table's second column basically defeats the purpose of usingX
columns. Please explain why you're using\verb
, i.e., what it is that you ultimately wish to accomplish in terms of formatting. – Mico Aug 21 '20 at 5:13