我正在尝试将里面的表格形象化fancyhead
。
该表格只有黄色的中央列。问题是,当我去编译并使用 Acrobat DC 打开文档时,我看不到单元格的顶行。
这是我的标记:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage[hidelinks]{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fancyhdr}
\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}
\setlength{\parindent}{0.95cm}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
\begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.5cm}|}
\hline
codice di riparto &
\cellcolor{yellow}\centering
TITLE \\
vediamo cosa c'è\\ ma poi cosa succede &
\centering
\tiny{Pag. \thepage\ di \pageref{LastPage}\\
Data: 17/05/2013\\
Rev. 0}\tabularnewline
\hline
\end{tabular}
}
\thispagestyle{fancy}
\begin{document}
%\chapter{Chapter title}
%% add this if you want the fancy style also on the first page of a chapter:
\section{Section title}
\subsection{non lo so}
\lipsum[1-10]
\end{document}
我想知道我是否忘记了定义表格的某些内容,或者其单元格的颜色。
答案1
太长而无法成为评论:
您的代码很好。行的不可见部分是 pdf viewer 伪像的结果。例如,使用您的代码,我在 Sumatra pdf viewer 中获得以下结果:
无论如何,我建议您对代码进行以下小的修改(标记为% <---
):
\documentclass[a4paper,12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{array}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fancyhdr}
\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}
\usepackage[hidelinks]{hyperref} % <--- moved to last place in preamble
\setlength{\parindent}{0.95cm}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
\begin{tabular}{|m{3.0cm}|>{\centering}m{10.0cm}|>{\centering}m{2.5cm}|} % <---
\hline
codice di riparto
& \cellcolor{yellow}{TITLE \\ % <---
vediamo cosa c'è\\ ma poi cosa succede} % <---
& \tiny % <---
Pag. \thepage\ di \pageref{LastPage}\\
Data: 17/05/2013\\
Rev. 0 \tabularnewline
\hline
\end{tabular}
}
\thispagestyle{fancy}
\begin{document}
%\chapter{Chapter title}
%% add this if you want the fancy style also on the first page of a chapter:
\section{Section title}
\subsection{non lo so}
\lipsum[1-10]
\end{document}
编辑:
在评论中,您声称问题出在页眉的大小上。让我添加showframe
一个包,它显示了您的实际页面布局。有了它,并对表格宽度进行了微小的更改(它将具有文本宽度),结果是:
(红线表示页面布局)
从上图可以清楚的看到,页眉的高度比表格的高度大很多。上图由以下 MWE 生成:
\documentclass[a4paper,12pt]{article}
\usepackage[demo]{graphicx}
\usepackage{array}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fancyhdr}
\usepackage[hmargin=2cm,top=4cm,
headheight=65pt,footskip=65pt]{geometry}
\usepackage[hidelinks]{hyperref} % <--- moved to last place in preamble
%---------------- show page layoutdon't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\setlength{\parindent}{0.95cm}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{\setlength\arrayrulewidth{0.5pt}%
\begin{tabular}{|m{3cm}|
>{\centering}m{\dimexpr\linewidth-5.5cm-6\tabcolsep-4\arrayrulewidth}|
>{\centering}m{2.5cm}|} % <---
\hline
codice di riparto
& \cellcolor{yellow}{TITLE \\ % <---
vediamo cosa c'è\\ ma poi cosa succede} % <---
& \tiny % <---
Pag. \thepage\ di \pageref{LastPage}\\
Data: 17/05/2013\\
Rev. 0 \tabularnewline
\hline
\end{tabular}
}
\thispagestyle{fancy}
\begin{document}
\section{Section title}
\subsection{non lo so}
\lipsum[1-10]
\end{document}
答案2
规则是存在的,但 PDF 查看器可能不会显示它。
一些更好的代码:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage[hidelinks]{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fancyhdr}
\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}
\setlength{\parindent}{0.95cm}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
\begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.5cm}|}
\hline
codice di riparto &
\cellcolor{yellow}\centering
TITLE \\
vediamo cosa c'è\\ ma poi cosa succede &
\centering
\tiny{Pag. \thepage\ di \pageref{LastPage}\\
Data: 17/05/2013\\
Rev. 0}\tabularnewline
\hline
\end{tabular}
}
\thispagestyle{fancy}
\begin{document}
%\chapter{Chapter title}
%% add this if you want the fancy style also on the first page of a chapter:
\section{Section title}
\subsection{non lo so}
\lipsum[1-10]
\end{document}
根据分辨率和放大倍数,规则可能看起来会消失。