禁忌表中多行单元格中的图形的垂直对齐

禁忌表中多行单元格中的图形的垂直对齐

我们有一张tabu包含数字和\multirow单元格的表格,其中包含一个长数字(XeLaTeX已使用)。最小工作示例在最后。

图表(箭头)附于实际结果之后。

对齐规则

  • 列标题居中(垂直和水平)、彩色且加粗;
  • 1,2,4列垂直居中,水平靠左边缘;
  • 3.5 列 – 垂直和水平均居中。

通过设置

\taburulecolor{DarkBlue}
\tabulinesep = 2mm
\begin{tabu} to 170 mm {
        |X[2,m]
        |X[1.5,m]
        |X[0.6, C,m]
        |X[2,m]
        |X[0.6, C,m]|
        }


\rowfont{\centering\bfseries\color{Blue}}

第 5 列的多行单元格中有一个图形\multirow{8}{*}{\includegraphics[height=8cm]{arrow.PNG}}。它没有与垂直中心对齐。为什么?该怎么办?

实际的

箭

平均能量损失

\documentclass[10pt, oneside, a4paper]{report}
\usepackage[left=2cm,right=1.5cm,
    top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{indentfirst} 
\usepackage{titlesec}
\usepackage{tabu}
\usepackage[svgnames]{xcolor}
\definecolor{DarkBlue}{HTML}{0070C0} 
\definecolor{Blue}{HTML}{1C8CCC} 
\usepackage{multirow}
\usepackage{polyglossia}
\setmainfont[Ligatures=TeX]{Arial}


%--------------------------------------------
\begin{document}

\taburulecolor{DarkBlue}
\tabulinesep = 2mm
\begin{tabu} to 170 mm {
        |X[2,m]
        |X[1.5,m]
        |X[0.6, C,m]
        |X[2,m]
        |X[0.6, C,m]|
        }


\rowfont{\centering\bfseries\color{Blue}}

\hline

Status
    & Visual indication
    & Symbol
    & Audible signal
    & Priority\\ \hline

Alarm active, not acknowledge 
    & Red, blinking 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Accompanied by an audible signal, as 3 short audible signals repeated every 7 s
    & High 
    \\ \hline

Alarm active, silenced 
    & Red, blinking 
    & picture % \includegraphics[width=0.5cm]{symbol.png} 
    & Silent 
    & \multirow{8}{*}{\includegraphics[height=8cm]{arrow.PNG}} 
    \\    \tabucline{1-4}

Warnings active, not acknowledged
    & Yellowish orange, blinking 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Accompanied by an audible signal, as 2 short audible signals, to be repeated at least once per 5 min or be replaced by an alarm 
    & \\ \tabucline{1-4}

Warnings active, silenced 
    & Yellowish orange, blinking 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent 
    &   \\ \tabucline{1-4}

Rectified --- unacknowledged alarm
    & Visual indication 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent 
    & \\ \tabucline{1-4}

Rectified --- unacknowledged warning
    & Visual indication 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent 
    & \\ \tabucline{1-4}

Alarm active, acknowledged 
    & Visual indication 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Suppression of audible signal (silent)
    & \\ \tabucline{1-4}

Warnings active, acknowledged
    & Visual indication 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent 
    &  \\ \hline

Caution active 
    & Yellow 
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent 
    & Low \\ \hline

Normal state 
    & Empty field 
    & None
    & Silent 
    &  \\ \hline

\end{tabu}
\end{document}

答案1

在此处输入图片描述

  • [export]{adjustbox}添加了用于确定图像垂直中心基线的包
  • 将跨越的行数修正multirow为 13(您需要计算跨越行中的所有行)
  • 使用选项=\multirow保留单元格中的列格式
  • 添加了缺失的graphicx包(选项演示仅用于测试目的,因为我没有您的图像)

\documentclass[10pt, oneside, a4paper]{report}
\usepackage[left=2cm,right=1.5cm,
    top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
%\usepackage{indentfirst}
%\usepackage{titlesec}
\usepackage{tabu}
\usepackage[svgnames]{xcolor}
\definecolor{DarkBlue}{HTML}{0070C0}
\definecolor{Blue}{HTML}{1C8CCC}
\usepackage{multirow}
%\usepackage{polyglossia}
%\setmainfont[Ligatures=TeX]{Arial}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}


%--------------------------------------------
\begin{document}

\taburulecolor{DarkBlue}
\tabulinesep = 2mm
\begin{tabu} to 170 mm {
        |X[2,m]
        |X[1.5,m]
        |X[0.6, C,m]
        |X[2,m]
        |X[0.6, C,m]|
        }
\rowfont{\centering\bfseries\color{Blue}}
    \hline
Status
    & Visual indication
    & Symbol
    & Audible signal
    & Priority\\ \hline

Alarm active, not acknowledge
    & Red, blinking
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Accompanied by an audible signal, as 3 short audible signals repeated every 7 s
    & High
    \\ \hline

Alarm active, silenced
    & Red, blinking
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent
    & \multirow{13}{=}{\includegraphics[height=8cm,             % <--- span 13 lines of text
                                       width=\linewidth,        % <---
                                       valign=m]{arrow.PNG}}    % <---
    \\    \tabucline{1-4}

Warnings active, not acknowledged
    & Yellowish orange, blinking
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Accompanied by an audible signal, as 2 short audible signals, to be repeated at least once per 5 min or be replaced by an alarm
    & \\ \tabucline{1-4}

Warnings active, silenced
    & Yellowish orange, blinking
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent
    &   \\ \tabucline{1-4}

Rectified --- unacknowledged alarm
    & Visual indication
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent
    & \\ \tabucline{1-4}

Rectified --- unacknowledged warning
    & Visual indication
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent
    & \\ \tabucline{1-4}

Alarm active, acknowledged
    & Visual indication
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Suppression of audible signal (silent)
    & \\ \tabucline{1-4}

Warnings active, acknowledged
    & Visual indication
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent
    &  \\ \hline

Caution active
    & Yellow
    & picture % \includegraphics[width=0.5cm]{symbol.png}
    & Silent
    & Low \\ \hline

Normal state
    & Empty field
    & None
    & Silent
    &  \\ \hline

\end{tabu}
\end{document}

相关内容