2

I am trying to format a LaTeX table (I am using ShareLaTeX online), and I want to do something special that I can't seem to figure out how to do. I think it involves using the multirow command but I am unsure. My code:

\begin{table}[h!] \centering \caption{VFD Parameter Settings (User and Basic)} \label{tab: VFD Parameter Settings1} \begin{tabular}{|l|l|l|p{3cm}|p{4.5cm}|} \hline Setting & Function & Value & Units/Description & Source/Reasoning \\ \hline \hline 00-10 & Control Mode & 0 & Speed Mode & To control speed \\ \hline 00-11 & Control of Speed Mode & 6 & PM Sensorless & (Open-Loop) For use with PMAC motors \\ \hline & & 4 & PM Vector + Encoder & (Closed-Loop) For Encoder control \\ \hline 00-20 & Source of Freq. Command & 0 & Digital Keypad & (Manual) Manually control freq. w/ keypad \\ \hline & & 5 & Pulse Input w/ Direction & (Auto) To control speed with Arduino pulses \\ \hline 00-21 & Source of Op. Command & 0 & Digital Keypad & (Manual) Manually control Start/Stop w/ keypad \\ \hline & & 1 & External Terminals & (Auto) To control Start/Stop with Arduino \\ \hline 00-23 & Control Motor Direction & 0 & Enable Fwd/Rev & Allow for both fwd and rev motion \\ \hline 00-32 & Keypad STOP function & 1 & STOP key enabled & Allows for STOP key to work in auto mode \\ \hline 01-00 & Max Operation Frequency & 200 & Hz & Frequency for rated speed of 3000RPM \\ \hline 01-01 & Output Frequency & *variable & Hz & (Open-Loop) Controls motor speed. Generally used 20-50Hz. \\ \hline 01-02 & Output Voltage & 115 & Vrms & Rated Bus Voltage from actuator nameplate \\ \hline 01-12 & Acceleration Time & *variable & seconds & Controls speed to ramp up. Used .05s. \\ \hline 01-13 & Deceleration Time & *variable & seconds & Controls speed to ramp down. Used .05s. \\ \hline 01-45 & Time Unit of Accel/Decel & 0 & 0.01 seconds & So accel/decel time is in units of 0.01s \\ \hline \end{tabular} \end{table} 

This compiles as: enter image description here

For parameters 00-11, 00-20, and 00-21, I would like to combine and center the two rows of only the first two columns, eliminating the blank cells. I want to make it clear these parameters have two options depending on the control type. Here is an example of how I would like it to look from MS Excel: enter image description here

How do I go about doing this? I'm also aware the formatting in general isn't great, any other fixes you could recommend would be appreciated.

2 Answers 2

1

Use m for the last column and \multirow for the cells to be merged changing the respective \hlines to \clines.

\documentclass{article} \usepackage{array,multirow} \usepackage[margin=1in]{geometry} \begin{document} \newcommand*{\mr}[1]{\multirow{2}[4]{*}{#1}} \begin{table} \centering \caption{VFD Parameter Settings (User and Basic)} \label{tab: VFD Parameter Settings1} \begin{tabular}{|l|l|l|>{\raggedright}m{3cm}|m{4.5cm}|} \hline Setting & Function & Value & Units/Description & Source/Reasoning \\ \hline \hline 00-10 & Control Mode & 0 & Speed Mode & To control speed \\ \hline \mr{00-11} &\mr{Control of Speed Mode} & 6 & PM Sensorless & (Open-Loop) For use with PMAC motors \\ \cline{3-5} & & 4 & PM Vector + Encoder & (Closed-Loop) For Encoder control \\ \hline \mr{00-20} &\mr{Source of Freq. Command}& 0 & Digital Keypad & (Manual) Manually control freq. w/ keypad \\ \cline{3-5} & & 5 & Pulse Input w/Direction & (Auto) To control speed with Arduino pulses \\ \hline \mr{00-21} &\mr{Source of Op. Command} & 0 & Digital Keypad & (Manual) Manually control Start/Stop w/ keypad \\ \cline{3-5} & & 1 & External Terminals & (Auto) To control Start/Stop with Arduino \\ \hline 00-23 & Control Motor Direction & 0 & Enable Fwd/Rev & Allow for both fwd and rev motion \\ \hline 00-32 & Keypad STOP function & 1 & STOP key enabled & Allows for STOP key to work in auto mode \\ \hline 01-00 & Max Operation Frequency & 200 & Hz & Frequency for rated speed of 3000RPM \\ \hline 01-01 & Output Frequency & *variable & Hz & (Open-Loop) Controls motor speed. Generally used 20-50Hz. \\ \hline 01-02 & Output Voltage & 115 & Vrms & Rated Bus Voltage from actuator nameplate \\ \hline 01-12 & Acceleration Time & *variable & seconds & Controls speed to ramp up. Used .05s. \\ \hline 01-13 & Deceleration Time & *variable & seconds & Controls speed to ramp down. Used .05s. \\ \hline 01-45 & Time Unit of Accel/Decel & 0 & 0.01 seconds & So accel/decel time is in units of 0.01s \\ \hline \end{tabular} \end{table} \end{document} 

enter image description here

3
  • Thank you very much! Great solution! Is there a way that I can avoid words being split in a cell and instead have them be in a new line in the cell? (Like En-coder in row 4 and Di-rection in row 6) Commented Jun 16, 2017 at 11:58
  • @RyanMcGrady -- Yes, just add >{\raggedright} before the p{3cm} column specification. Commented Jun 16, 2017 at 16:28
  • Please see my edit. Commented Jun 16, 2017 at 16:33
0

Here are some improvements and simplifications:

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{geometry} \usepackage{ragged2e} \usepackage[table, svgnames]{xcolor} \usepackage{array, multirow, caption, hhline} \newcommand\colhead[1]{\multicolumn{1}{c}{\bfseries#1}} \newcommand\myhhline{\hhline{>{\arrayrulecolor{black}}|>{\arrayrulecolor{Gainsboro}}-|-|-|-|->{\arrayrulecolor{black}}|}} \begin{document} \begin{table}[!htb] \centering\setlength\tabcolsep{3pt} \renewcommand{\arraystretch}{1.5} \setlength\arrayrulewidth{0.8pt} \caption{VFD Parameter Settings (User and Basic)} \label{tab: VFD Parameter Settings1} \begin{tabular}{|l!{\color{Gainsboro}\vrule width1pt}l!{\color{Gainsboro}\vrule width1pt}l!{\color{Gainsboro}\vrule width1pt}>{\RaggedRight}m{3cm}!{\color{Gainsboro}\vrule width1pt}>{\RaggedRight}m{4cm}|} \colhead{Setting} & \colhead{Function} & \colhead{Value} & \colhead{Units/Description} & \colhead{Source/Reasoning} \\[1ex] \hline 00-10 & Control Mode & 0 & Speed Mode & To control speed \\ \myhhline 00-11 & Control of Speed Mode & 6 & PM Sensorless & (Open-Loop) For use with PMAC motors \\ \myhhline & & 4 & PM Vector + Encoder & (Closed-Loop) For Encoder control \\ \myhhline 00-20 & Source of Freq. Command & 0 & Digital Keypad & (Manual) Manually control freq. w/ keypad \\ \myhhline & & 5 & Pulse Input w/ Direction & (Auto) To control speed with Arduino pulses \\ \myhhline 00-21 & Source of Op. Command & 0 & Digital Keypad & (Manual) Manually control Start/Stop w/ keypad \\ \myhhline & & 1 & External Terminals & (Auto) To control Start/Stop with Arduino \\ \myhhline 00-23 & Control Motor Direction & 0 & Enable Fwd/Rev & Allow for both fwd and rev motion \\ \myhhline 00-32 & Keypad STOP function & 1 & STOP key enabled & Allows for STOP key to work in auto mode \\ \myhhline 01-00 & Max Operation Frequency & 200 & Hz & Frequency for rated speed of 3000RPM \\ \myhhline 01-01 & Output Frequency & *variable & Hz & (Open-Loop) Controls motor speed. Generally used 20-50Hz. \\ \myhhline 01-02 & Output Voltage & 115 & Vrms & Rated Bus Voltage from actuator nameplate \\ \myhhline 01-12 & Acceleration Time & *variable & seconds & Controls speed to ramp up. Used .05s. \\ \myhhline 01-13 & Deceleration Time & *variable & seconds & Controls speed to ramp down. Used .05s. \\ \myhhline 01-45 & Time Unit of Accel/Decel & 0 & 0.01 seconds & So accel/decel time is in units of 0.01s \\ \hline \end{tabular} \end{table} \end{document} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.