我的第二个代码(解决前两个问题之后)

我的第二个代码(解决前两个问题之后)

我正在尝试在 Texmaker 中创建如下表。

在此处输入图片描述

这里我面临以下问题。

  1. 将第 4 至第 6 列标题换行并居中对齐。
  2. 段落 [第 3 行最后一列] 上的 Hspace 不起作用
  3. 最后的多行包含来自其前一行的元素。

下面的屏幕截图。问题以红框突出显示

在此处输入图片描述

以下是完整的代码...请帮我解决这些问题。

\documentclass[12pt,a4paper,titlepage]{report}
\usepackage{array}
\usepackage{booktabs, multicol, multirow}
\usepackage{color, textcomp, listings}
\usepackage{rotating}
\usepackage[table]{xcolor}
\usepackage{pbox}

\begin{document}
% Table generated by Excel2LaTeX from sheet 'All Exp Table'
\begin{table}[!htbp]
  \centering
  \renewcommand\baselinestretch{1}\normalsize
  \renewcommand{\arraystretch}{1.2}
  \begin{tabular}{|c|c|c|m{.5 cm}|m {.5 cm}|m{.5 cm}|m {10.5 cm}|}
\hline
    {\begin{sideways} {\centering { Rule No} } \end{sideways}}& {\begin{sideways} {\centering { F\_offsetFlag } } \end{sideways}} & {\begin{sideways} {\centering { B\_offsetFlag } } \end{sideways}} &      \multicolumn{1}{m {.5 cm}}{\begin{sideways} { F\_offsetDiff Relation  MaxBlkSize} \end{sideways}} & 
\multicolumn{1}{m {.5 cm}}{\begin{sideways} { B\_offsetDiff (Relation) MaxBlkSize} \end{sideways}} &
\multicolumn{1}{m {.5 cm}}{\begin{sideways} { F\_offsetDiff (Relation) B\_offsetDiff } \end{sideways}} &  {\textbf{Action}} \\     \hline
1     & F     & F     & $<$     &  & =     & \pbox{10 cm}{writeBlockAndUpdateOffsets(f\_buf,f\_hash,null);} \\ \hline
2     & F     & F     & =     & {} & $>$     & \multicolumn{1}{l} { \pbox{10 cm}{If (hasBlockHashOnHBase(next\_b\_hash)) \\ \hspace{1 cm} byte[] buf = Arrays.copyOfRange(f\_buf, 0, (int)(b\_offset-offset)); \\ \hspace{1 cm} recordBlockAndUpdateOffsets(buf,null,null); \\
Else \\ WriteBlockAndUpdateOffsets(f\_buf,f\_hash,null); } }\\ \hline
3     & F     & F     &       & = & =     & \multicolumn{1}{l}{\multirow{2}[4]{*}{writeBlockAndUpdateOffsets(b\_buf,b\_hash,null);}} \\ \cline{1-6}
4     & F     & F     &       & {=} & $>$     & \multicolumn{1}{l}{} \\ \hline
5     & F     & T     &       & {$<$} & =     & \pbox{10 cm}{byte[] buf = Arrays.copyOfRange(b\_buf, (maxBlockSize-lastBlkSize), b\_buf.length); \\
recordSuperBlockAndUpdateOffsets (buf,null,b\_hash+","+(maxBlockSize-lastBlkSize)+","+buf.length);} \\ \hline
6     & F     & T     &       & {$<$} &       & \pbox{10 cm}{If (offset==0)\\
IncrementBlockAndUpdateOffsets(b\_hash,b\_BlkSize);\\
Else\\
byte[] buf = Arrays.copyOfRange(b\_buf, (maxBlockSize-lastBlkSize), b\_buf.length);\\
recordSuperBlockAndUpdateOffsets(buf,null,b\_hash+","+ (maxBlockSize-lastBlkSize)+","+buf.length); } \\ \hline

9     & T     & F     & $<$     & {} & =     & \multicolumn{1}{l}{\multirow{2}[4]{*}{incrementBlockAndUpdateOffsets(f\_hash,f\_BlkSize);}} \\ \cline{1-6}
10    & T     & F     & =     & {} &       & \multicolumn{1}{l}{} \\ \hline
11    & T     & F     & =     & {} & =     & \multicolumn{1}{l}{\multirow{2}[4]{10 cm}{{byte[] buf = Arrays.copyOfRange(b\_buf, 0, (maxBlockSize-lastBlkSize));\\ recordBlockAndUpdateOffsets(buf,null,null);\\ incrementBlockAndUpdateOffsets(f\_hash,f\_BlkSize);}}} \\ \cline{1-6}
12    & T     & F     & $>$     & {} &       & \multicolumn{1}{l}{} \\ \hline
13    & T     & T     & $<$     & {} & =     & \multicolumn{1}{l}{\multirow{2}[4]{*}{incrementBlockAndUpdateOffsets(f\_hash,f\_BlkSize);}} \\ \cline{1-6}
14    & T     & T     & =     & {} & $>$     & \multicolumn{1}{l}{} \\ \hline
\end{tabular}%
\caption{}
  \label{tab:ImplLogic2}%
\end{table}%
\end{document}

===============================================

我的第二个代码(解决前两个问题之后)

\documentclass[12pt,a4paper,titlepage]{report}
\usepackage{array}
\usepackage{booktabs, multicol, multirow}
\usepackage{color, textcomp, listings}
\usepackage{rotating}
\usepackage[table]{xcolor}
\usepackage{pbox}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'All Exp Table'
\begin{table}[!htbp]

\renewcommand\baselinestretch{1}\normalsize
  \renewcommand{\arraystretch}{1.2}
 \begin{tabular}{|c|c|c|m{1.3 cm}| m{1.3 cm}|m{1.3 cm}|>{\raggedright\arraybackslash}m{8.8 cm}|}
\hline

\rotatebox{90}{\parbox{2 cm}{\centering Rule No}}&
\rotatebox{90}{\parbox{2 cm}{\centering F\_offsetFlag}}&
\rotatebox{90}{\parbox{2 cm}{\centering B\_offsetFlag}}&
\rotatebox{90}{\parbox{2.2 cm}{\centering F\_offsetDiff (Relation) MaxBlkSize}}&
\rotatebox{90}{\parbox{2.2 cm}{\centering B\_offsetDiff (Relation) MaxBlkSize}}&
\rotatebox{90}{\parbox{2.2 cm}{\centering F\_offsetDiff (Relation) B\_offsetDiff}}& 
{\centering {\textbf{Action}}} \\
    \hline
1     & F     & F     & \centering$<$     &  & \centering =     & {writeBlockAndUpdateOffsets(f\_buf,f\_hash,null);} \\ \hline
2     & F     & F     & \centering =     &  & \centering$>$     &  {If (hasBlockHashOnHBase(next\_b\_hash)) \\ \hspace*{.2 cm}byte[] buf = Arrays.copyOfRange(f\_buf, 0, (int)(b\_offset-offset)); \\ \hspace*{.2 cm}recordBlockAndUpdateOffsets(buf,null,null); \\ Else \\ \hspace*{.2 cm}writeBlockAndUpdateOffsets(f\_buf,f\_hash,null); } \\ \hline
3     & F     & F     &       & \centering = & \centering =     & {\multirow{2}[4]{*}{writeBlockAndUpdateOffsets(b\_buf,b\_hash,null);}} \\ \cline{1-6}
4     & F     & F     &       & \centering = & \centering $>$     &  \\ \hline
5     & F     & T     &       & \centering $<$ & \centering =     & \pbox{8.8 cm}{byte[] buf = Arrays.copyOfRange(b\_buf, (maxBlockSize-lastBlkSize), b\_buf.length); \\
recordSuperBlockAndUpdateOffsets (buf,null,b\_hash+","+(maxBlockSize-lastBlkSize)+","+buf.length);} \\ \hline
6     & F     & T     &       & \centering $<$ &       & \pbox{8.8 cm}{If (offset==0)\\
\hspace*{.2 cm}IncrementBlockAndUpdateOffsets (b\_hash,b\_BlkSize);\\
Else\\
\hspace*{.2 cm}byte[] buf = Arrays.copyOfRange(b\_buf, (maxBlockSize-    lastBlkSize),b\_buf.length);\\
\hspace*{.2 cm}recordSuperBlockAndUpdateOffsets (buf,null,b\_hash+","+(maxBlockSize-lastBlkSize)+","+buf.length); } \\ \hline

9     & T     & F     & \centering $<$     &  & \centering =     & {\multirow{2}[4]{*}{incrementBlockAndUpdateOffsets(f\_hash,f\_BlkSize);}} \\ \cline{1-6}
10    & T     & F     & \centering =     &  &       &  \\ \hline
11    & T     & F     & \centering =     &  & \centering =     & {\multirow{2}[4]{8.8 cm}{byte[] buf = Arrays.copyOfRange(b\_buf, 0, (maxBlockSize-lastBlkSize));\\     recordBlockAndUpdateOffsets(buf,null,null);\\     incrementBlockAndUpdateOffsets(f\_hash,f\_BlkSize);}} \\ \cline{1-6}
12    & T     & F     & \centering $>$     &  &       &  \\ \hline
13    & T     & T     & \centering $<$     &  & \centering =   & {\multirow{2}[4]{*}{incrementBlockAndUpdateOffsets(f\_hash,f\_BlkSize);}} \\ \cline{1-6}
14    & T     & T     & \centering =     &  & \centering $>$ &  \\ \hline

    \end{tabular}%
\caption{}
  \label{tab:ImplLogic2}%
\end{table}%

\end{document}

当前文件输出粘贴如下,问题以红色框突出显示 在此处输入图片描述

答案1

你并不真正想要rotating主要用于sdewatstable包(sideways环境实际上只是为了与 LaTeX2.09 版本语法兼容)你只需要graphicxrotating无论如何在内部使用)然后

\rotatebox{90}{\parbox{2cm}{\centering B\_offsetDiff (Relation) MaxBlkSize}

或者

\rotatebox{90}{\begin{tabular}{@{}c@{}}B\_offsetDiff\\ (Relation)\\ MaxBlkSize\end{tabular}}

另外,最后一列的使用间隔很大

 >{\raggedright\arraybackslash}m{10.5cm}

因此该列的右侧设置不整齐。(删除\pbox您不需要的部分)

\\ \hspace{1 cm} 

行首的空格总是被丢弃,使用星号形式\hspace*{1cm}来保留它。

我不确定你用多行的目的是什么,但是

\multicolumn{1}{l}{\multicolumn

看起来不对,我怀疑你不想要外面的 \multicolumn`

相关内容