表格内的间距/对齐(tabularx、页眉、页脚)

表格内的间距/对齐(tabularx、页眉、页脚)

我不明白表格内部的间距(文本和图片之前)。我使用表格环境,很难删除表格开头的空格。还有一个问题,为什么命令:将偶数页码居中不起作用? 在此处输入图片描述

    \documentclass[9pt,a4paper,titlepage]{book} 
\usepackage[top=2.5cm,left=5.5cm,footskip=2.5cm, right=2.5cm, headheight=1.3cm, headsep=12pt]{geometry}
\usepackage{comment}
\usepackage[svgnames,table]{xcolor}
\usepackage{array, boldline, makecell, booktabs}
\newcommand\btrule[1]{\specialrule{#1}{0pt}{0pt}}
\usepackage{etoolbox,fancyhdr}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\definecolor{gray}{RGB}{145,145,145}
\headrulecolor{gray}
\usepackage{makecell,multirow,tabularx}
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyheadoffset[LO,RE]{25mm}
\fancyhf{}
\fancyhead[LE]
{%
    \begin{tabularx}{1.1923\textwidth}{@{}ll!{\color{gray}\vrule width 1mm}l X@{}}    
    &\includegraphics[scale=1]{ex.jpg}&           \\
   \arrayrulecolor{gray}\btrule{1mm}
    \end{tabularx}%
            }
\fancyhead[RO]{%
    \begin{tabularx}{1.1923\textwidth}{X l!{\color{gray}\vrule width 1mm}l} 
    &&\includegraphics[scale=1]{ex.jpg}        \\
\arrayrulecolor{gray}\btrule{1mm}
    \end{tabularx}%
            }
\fancyfootoffset[LO,RE]{25mm}
\fancyfoot{}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\fancyfoot[LE]
{%
     \begin{tabularx}{1.1923\textwidth}{ll!{\color{gray}\vrule width 1mm}R} \arrayrulecolor{gray}\btrule{1mm}   
    & \thepage &\textit{Name of the \textbf{device}}
      \\
      \end{tabularx}%
            }

\fancyfoot[RO]{%
    \begin{tabularx}{1.1923\textwidth}{Lp{131mm}!{\color{gray}\vrule width 1mm}C} 
\arrayrulecolor{gray}\btrule{1mm}
    & \textit{Name of the \textbf{device}}&\thepage\\
    \end{tabularx}%
            }
\graphicspath{{C:/}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
chepter 1
\newpage
sth
\newpage
\end{document}

感谢你。

答案1

这对我有用。如何使用表中的列很重要。

\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\definecolor{gray}{RGB}{145,145,145}
\headrulecolor{gray}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\headrulewidth}{1mm}
\fancyhead[LE]
{%
    \begin{tabularx}{\textwidth}{l!{\color{gray}\vrule width 1mm}l X}    
    \includegraphics[scale=1]{ex.jpg}&\\
     \end{tabularx}%
            }
\fancyhead[RO]{%
    \begin{tabularx}{\textwidth}{X l!{\color{gray}\vrule width 1mm}l} 
    &&\includegraphics[scale=1]{ex.jpg}        \\
    \end{tabularx}%
            }
\fancyfoot{}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\fancyfoot[LE]
{%
     \begin{tabularx}{1.23\textwidth}{c!{\color{gray}\vrule width 1mm}R}    \arrayrulecolor{gray}\btrule{1mm}
    \thepage & \textit{Name of the\textbf{device}}
      \\
      \end{tabularx}%
            }

\fancyfoot[RO]{%
    \begin{tabularx}{1.23\textwidth}{L!{\color{gray}\vrule width 1mm}lC} 
\arrayrulecolor{gray}\btrule{1mm}
    \textit{Name of the \textbf{device}}&\thepage\\
    \end{tabularx}%
            }

相关内容