2

I have the following piece of code using the memoir class from asudis:

\newcommand*{\pointsize}{12pt}
\documentclass[letterpaper,             % Use US letter-size paper
                       oneside,                 % No verso and recto differences
                       \pointsize]              % Uses the font size defined above
                       {memoir}
\usepackage{booktabs}

\usepackage{multirow} \begin{document}
\begin{table} \begin{tabularx}{\textwidth}{@{} p{0.15\textwidth}p{0.15\textwidth}p{0.15\textwidth}p{0.2\textwidth}p{0.25\textwidth}@{}} \toprule Node name & Type & Conditional dependcy & States & Description \ \midrule Prior & \multirow{6}{}{Initial ($t=0$)} & None & 11 states indicating score in the range {[}0-10{]} & A state of 0 denotes a student who scored a 0 in the pre-test while a state of 10 represents a student who scored 100% in the pre-test \ \cmidrule(r){1-1} \cmidrule(l){3-5} Knowledge0 & & Prior & \multirow{10}{}{True and False} & State of true denotes the possibility that the student has the required knowledge at timestep $t=0$ \ \cmidrule(r){1-1} \cmidrule(lr){3-3} \cmidrule(l){5-5} Distractor00 & & \multirow{5}{}{Knowledge0} & & \multirow{3}{}{True denotes the evidence that the student has collected this distractor at timestep $t=0$} \ \cmidrule(r){1-1} Distractor01 & & & & \ \cmidrule(r){1-1} Distractor02 & & & & \ \cmidrule(r){1-1} \cmidrule(l){5-5} Question0 & & & & True denotes the evidence that the student answered the quiz correctly at timestep $t=0$ \ \cmidrule(r){1-2} \cmidrule(l){5-5} Knowledge1 & \multirow{5}{}{Temporal ($t=1,2,3$)} & & & True denotes the possibility that the student has the required knowledge at timestep $t=1,2,3$ \ \cmidrule(r){1-1} \cmidrule(lr){3-3} \cmidrule(l){5-5} Distractor10 & & \multirow{4}{}{Knowledge1} & & \multirow{3}{*}{True denotes the evidence that the student has collected this distractor at timestep $t=1,2,3$} \ \cmidrule(r){1-1} Distractor11 & & & & \ \cmidrule(r){1-1} Distractor12 & & & & \ \cmidrule(r){1-1} \cmidrule(l){5-5} Question1 & & & & True denotes the evidence that the student answered the quiz correctly at timestep $t=1,2,3$ \ \bottomrule \end{tabularx} \end{table} \end{document}

Which is rendering the table as follows. I have no idea why the text in the 3rd and 5th row of last column is not wrapping up like the rest of the rows above and below it.

Additionally, how do I make the 7th row 2nd column wrap like the others? enter image description here

Vipin Verma
  • 205
  • 1
  • 9
  • 2
    not directly related but tabularx with no X column can not do anything useful, just use a normal tabular – David Carlisle Feb 18 '21 at 08:41
  • 1
    Your example generates errors, starting with ! Undefined control sequence.<argument> \pointsize – David Carlisle Feb 18 '21 at 08:44
  • using tabular instead gives error regarding textwidth – Vipin Verma Feb 18 '21 at 08:45
  • add \newcommand*{\pointsize}{12pt} at the top – Vipin Verma Feb 18 '21 at 08:47
  • @vipin8169 yes, if you're using tabular you don't specify a total width, hence the error regarding \textwidth, correct would be \begin{tabular}{<columns>}<body>\end{tabular} instead. – Skillmon Feb 18 '21 at 08:48
  • 2
    yes of course you need to remove that argument as well (it is not being used in any case) , No sorry please supply a usable test file that produces the output you are asking about, do not make us guess what the code is that we have to correct. – David Carlisle Feb 18 '21 at 08:48
  • i updated the code above and added \newcommand*{\pointsize}{12pt} – Vipin Verma Feb 18 '21 at 08:49
  • 1
    The code is still not compilable, at the least it's missing \begin{document} and \end{document}. – Skillmon Feb 18 '21 at 08:51
  • please test the code you post: you have added a definition of \pointsize but after it is used so it gives the same error. It is using an undefined environment tabularx it has no \begin{document} etc. – David Carlisle Feb 18 '21 at 08:51
  • 1
    The issue why there are no automatic linebreaks is because you're using \multirow. – Skillmon Feb 18 '21 at 08:53
  • Did you try to run the code you just posted? Does it run without errors on your machine and/or provide the output you show us in the image? Also, as an aside, memoir is not from asudis, but they use memoir in their template. – Skillmon Feb 18 '21 at 09:02
  • I was able to make it work by specifying the width after multirow. thanks for the hint. \multirow{5}{*}{\linewidth}{Temporal ($t=1,2,3$)} – Vipin Verma Feb 18 '21 at 09:03
  • the document that I am working is a 150 page long thesis, and is getting longer. it is very hard to crop everything and just give the table code. I tried to do that, but it came with error. sorry :/ – Vipin Verma Feb 18 '21 at 09:04
  • thanks for your hinti. it made me search for "multirow latex wraptext" and i found the solution in this post https://tex.stackexchange.com/questions/60884/text-wrapping-in-multirow-columns – Vipin Verma Feb 18 '21 at 09:05
  • No problem, and the first time was ok-ish, but it would've been much better if you tested the code after it was pointed out that the code contained errors. You tried to improve it, but as a matter of fact it still doesn't compile, because you're missing \usepackage{tabularx}, if you just did the same as we do, copied the code you posted into a new document and tried to run it, you would've seen that. – Skillmon Feb 18 '21 at 09:07
  • I tried that. but adding \usepackage{tabularx} does not let me compile it – Vipin Verma Feb 18 '21 at 09:11
  • it is giving the same error begin{document} missing even though it is not – Vipin Verma Feb 18 '21 at 09:14
  • there are so many classes in main tex file that i am not able to eliminate the ones required for an MWE :'( – Vipin Verma Feb 18 '21 at 09:18

1 Answers1

1

After making your document minimally compilable (e.g., by replacing the specious \pointsize option with 12pt), I determined that you (a) should get rid of all \multirow directives, (b) switch to a \small relative font size, and (c) reduce the value of \tabcolsep to 3pt (default: 6pt), and (d) reducing the widths of the first four rows and assigning the column type X to the final column in order to have a chance to make the table fit inside the text block.

That said, I can't figure out for the life of me what the various \cmidrule directives are supposed to accomplish. That's something for you to figure out.

enter image description here

\documentclass[letterpaper,             % Use US letter-size paper
               oneside,                 % No verso and recto differences
               12pt]                    % Use a specific font size
               {memoir}
\usepackage{booktabs,ragged2e,array}
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}
\newcolumntype{L}{>{\RaggedRight}X}

\begin{document} \begin{table} \small % switch to 11pt inside this 'table' env. \setlength\tabcolsep{3pt} % default: 6pt

\begin{tabularx}{\textwidth}{@{} P{0.12\textwidth} P{0.11\textwidth} P{0.13\textwidth} P{0.16\textwidth} L @{}} % use at least one column of (modified) type 'X' \toprule Node name & Type & Conditional dependcy & States & Description \ \midrule Prior & Initial ($t=0$) & None & 11 states indicating score in the range [0--10] & A state of 0 denotes a student who scored a 0 in the pre-test, while a state of 10 represents a student who scored 100% in the pre-test \ \cmidrule(r){1-1} \cmidrule{3-5} Knowledge0 & & Prior & True and False & State of true denotes the possibility that the student has the required knowledge at timestep $t=0$ \ \cmidrule(r){1-1} \cmidrule(r){3-3} \cmidrule{5-5} Distractor00 & & Knowledge0 & & True denotes the evidence that the student has collected this distractor at timestep $t=0$ \ \cmidrule(r){1-1} Distractor01 & & & & \ \cmidrule(r){1-1} Distractor02 & & & & \ \cmidrule(r){1-1} \cmidrule{5-5} Question0 & & & & True denotes the evidence that the student answered the quiz correctly at timestep $t=0$ \ \cmidrule(r){1-2} \cmidrule{5-5} Knowledge1 & Temporal ($t=1,2,3$) & & & True denotes the possibility that the student has the required knowledge at timestep $t=1,2,3$ \ \cmidrule(r){1-1} \cmidrule(r){3-3} \cmidrule{5-5} Distractor10 & & Knowledge1 & & True denotes the evidence that the student has collected this distractor at timestep $t=1,2,3$ \ \cmidrule(r){1-1} Distractor11 & & & & \ \cmidrule(r){1-1} Distractor12 & & & & \ \cmidrule(r){1-1} \cmidrule{5-5} Question1 & & & & True denotes the evidence that the student answered the quiz correctly at timestep $t=1,2,3$ \ \bottomrule \end{tabularx} \end{table} \end{document}

Skillmon
  • 60,462
Mico
  • 506,678
  • How were you able to make this code work. it is giving me 51 errors if I just use this piece of code in a standalone tex file. one of them being \begin{document} command was found – Vipin Verma Feb 18 '21 at 09:25
  • 1
    @vipin8169 it runs without error here. What is the first error you get (ignore later errors) – David Carlisle Feb 18 '21 at 09:27
  • 1
    Did you test the right file? The code you posted in the question was missing \begin{document} but Mico's answer has it on line 9 – David Carlisle Feb 18 '21 at 09:29
  • I pasted the Mico's answer in a single tex file and it gave me the error about missing begin>doc error among 51 errors. – Vipin Verma Feb 18 '21 at 09:30
  • 1st error was this l.5 \abx@aux@refcontext {apa/global//global/global} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,\hobx'), type I' and the correct spelling (e.g.,I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.` – Vipin Verma Feb 18 '21 at 09:31
  • but when i put the parts from Mico's code to respective places in the files it worked. – Vipin Verma Feb 18 '21 at 09:33
  • cmidrule is to put those horizontal lines between various rows. since it was a multirow environment – Vipin Verma Feb 18 '21 at 09:43
  • @vipin8169 - For sure, when I created the code above and compiled it to create the associated screenshot, there were no errors at all. I have no idea what you're doing to cause 51 error messages. Sadly -- but probably not surprisingly -- my mind-reading skills are simply worthless. You must be doing something to generate 51 error messages. However, unless you tell me specifically what it is that you're doing, please don't count on me to be able to magically guess it for you. – Mico Feb 18 '21 at 12:10
  • 2
    Try deleting your old aux file (clean project). – John Kormylo Feb 18 '21 at 22:13
  • Yeah, clearing the cache on overleaf worked for me. Much thanks! – Vipin Verma Feb 19 '21 at 04:49