1

I am unsure why the multirow is not vertically centered, any help is appreciated:

\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\newcommand{\mod}[2]{Module \# #1 -- #2}
\newcommand{\labentry}[1]{\multirow{3}{*}{\parbox{1.7in}{\raggedright#1}}}
\begin{document}
\begin{center}
\textbf{Chemistry 1407 Lecture/Lab Schedule\\
Spring 2017}
\end{center}
\begin{longtable}{clc>{\raggedright}p{2.16in}p{1.7in}}
\toprule
\parbox{0.62in}{\centering \textbf{Lecture \#}} & \textbf{Day} & \textbf{Date} & \textbf{Sections Covered} & \textbf{Labs} \\
\cmidrule(r){1-1} \cmidrule(r){2-3} \cmidrule(lr){4-4} \cmidrule(l){5-5}
\endhead
-- & Monday & 1--09 & Read D2L Introduction \& OWL Registration & \labentry{Check-in/Safety Rules}\\
1 & Wednesday & 1--11 & \mod{1}{Section 1.7} & \\
2 & Friday & 1--13 & \mod{1}{Sections 1.5--1.6, 1.9} & \\
\midrule
  • 1
  • Much appreciated, thanks! I can let someone know if I should leave this up, or delete the question – J M Jan 8 '17 at 20:37
  • @hakaze - I don't think the OP's issue is related to the earlier posting you indentified. I'd say, rather, that the \labentry macro isn't set up correctly: It is set to span 3 rows, yet the multi-line cell that's adjacent to the instance of \labentry spans only 2 rows. The \multirow directive is working exactly as it is supposed to. What needs to be fixed, then, is the structure of the \labentry macro. – Mico Jan 8 '17 at 21:48
  • Off-topic: I think the \mod macro should be defined as \newcommand{\mod}[2]{Module \##1 -- #2}, i.e., without the space after \#. – Mico Jan 8 '17 at 22:10
  • I did catch the error in \mod after posting and fixed that already – J M Jan 8 '17 at 22:15
2

I am unsure why the multirow is not vertically centered

Your \labentry macro is defined as follows:

\newcommand{\labentry}[1]{\multirow{3}{*}{\parbox{1.7in}{\raggedright#1}}}

Observe that it's set up to span a fixed number of rows: 3.

In the body of the longtable, there's the instruction

\labentry{Check-in/Safety Rules}

The vertical alignment issue arises because the material in the immediately adjacent cell spans only 2 rows, not 3 rows. One way to fix this is to redefine \labentry so that it's contents span only 2 rows, not 3. Or, redefine labentry so that it takes two arguments rather than 1; use the second argument to indicate the number of rows it's supposed to span.

Better still: Don't use \multirow at all here. There is simply no way that readers will not understand how the information in the "Labs" column is related to the information in the preceding "Sections covered" column.


Addendum to address the OP's follow-up comment:

I am using multirow, simply because I would like the "Labs" column to be vertically centered. Purely for aesthetics.

Be careful not to let your sense of aesthetics create unwanted ambiguity. To truly center the line "Check-in/Safety Rules" in the final column with regard to the information contained in the preceding columns, you should actually set aside 5 rows, not just 3 rows, in the \multirow directive. That's because the material in the preceding columns spans, well, 5 rows once you allow for the automatically generated line breaks.

If you do set aside 5 rows in the first argument of \multirow, there's a new and rather serious problem: How do you make sure that the students understand that "Check-in/Safety Rules" pertains to all three dates and not just to the middle date (Jan 11)? As the first half of the table shown below demonstrates, I (for one, and I don't think I'm alone) would immediately assume that "Check-in/Safety Rules" pertains only to the middle date. To truly avoid creating such an ambiguity, I think it's necessary to ditch the \multirow approach and repeat the salient information in the final column as often as is needed.

enter image description here

\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[justification=centering,font=bf]{caption} % <--- new
\usepackage{longtable,array,booktabs,multirow}
\newcommand{\mod}[2]{Module~\##1 --- #2}
%% I've modified the following macro to take 2 arguments
\newcommand{\labentry}[2]{\multirow{#1}{*}{\parbox{1.6in}{\raggedright #2}}}
\begin{document}
\begin{longtable}{@{} lll 
     >{\raggedright}p{2.16in} 
     >{\raggedright\arraybackslash}p{1.6in} @{}}
\caption*{Chemistry 1407 Lecture/Lab Schedule\\Spring 2017}\\
\toprule
\textbf{Lecture \#} & \textbf{Weekday} & \textbf{Date} & \textbf{Sections Covered} & \textbf{Labs} \\
\cmidrule(r){1-1} \cmidrule(lr){2-3} \cmidrule(lr){4-4} \cmidrule(l){5-5}
\endfirsthead
\toprule
\textbf{Lecture \#} & \textbf{Weekday} & \textbf{Date} & \textbf{Sections Covered} & \textbf{Labs} \\
\cmidrule(r){1-1} \cmidrule(lr){2-3} \cmidrule(lr){4-4} \cmidrule(l){5-5}
\endhead
\bottomrule
\endfoot
-- & Monday & 1--09 & Read D2L Introduction \& OWL Registration 
   & \labentry{5}{Check-in/Safety Rules}\\
1 & Wednesday & 1--11 & \mod{1}{Section 1.7} & \\
2 & Friday & 1--13 & \mod{1}{Sections 1.5--1.6, 1.9} & \\
\midrule
-- & Monday & 1--09 & Read D2L Introduction \& OWL Registration 
   & Check-in/Safety Rules\\
1 & Wednesday & 1--11 & \mod{1}{Section 1.7} & see above\\ % note the "see above" instructions
2 & Friday & 1--13 & \mod{1}{Sections 1.5--1.6, 1.9} & see above\\
\end{longtable}
\end{document} 
  • I am using multirow, simply because I would like the "Labs" column to be vertically centered. Purely for aesthetics. Why would I have it say 2 rows? I want it to span all of the rows in that block (the 3 rows), not just the two of the row that it is on. Plus the preceding entry still only spans one row (even though the text has wrapped, right?) – J M Jan 8 '17 at 22:14
  • 1
    +1 mainly for telling to avoid \multirow here. – egreg Jan 8 '17 at 22:25
  • 1
    @J.M. - The first 3 "logical" rows span 5 physical rows, because of the two automatic linebreaks in the column "Sections covered". If you have to vertically center the material in the final column relative to the material in the preceding column(s), you should set aside 5, not 3, rows in the first argument of \multirow. However, doing so will immediately create a new, serious visual ambiguity: Does the string "Check-in/Safety Rules" apply just to the Jan 11 material, or does it apply to all three dates? Yet another reason to be weary of the effects produce by\multirow... – Mico Jan 8 '17 at 23:11
  • @Mico, I see, thank you for the explanation about the rows. As for the lab listing, students only have lab once/week. The "Sections Covered" is their lecture schedule, but there is more than one lab section. The schedule is general regardless of which day of the week the student has lab. Whether the student is in T or Th lab, they get the same schedule, because they all will do the same experiment that week. It is general so I don't have to maintain separate copies of the identical lab schedule (one with just an extra line for Tuesday and one with an extra line for Thursday listed). – J M Jan 9 '17 at 6:18
  • 1
    @JM - Thanks for these additional explanations. I still think you risk creating ambiguity by centering the contents of the "Labs" column vertically. The visual temptation to associate the contents of that column with the date shown to the left is going to be huge. Better, maybe, to (a) put in an explicit reminder that the lab schedules are separate from the lecture schedules and (b) place the lab-related information at the top of the column... – Mico Jan 9 '17 at 7:38

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.