![页眉中的图](https://linux22.com/image/272860/%E9%A1%B5%E7%9C%89%E4%B8%AD%E7%9A%84%E5%9B%BE.png)
对于我们的文档,我尝试将图像放入标题中,但不起作用。我已经尝试了多个代码,但无法解决我的问题fancyhdr
。有人有想法吗?
这是原始的猪圈表:
%%
%% This style is derived from the docbook one.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{asciidoc}[2008/06/05 AsciiDoc DocBook Style]
\RequirePackageWithOptions{docbook}
\@ifpackageloaded{xcolor}{
\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
}{
\usepackage[usenames,dvipsnames]{xcolor}
}
\setlength{\parindent}{2em}
\linespread{1.3}
\thispagestyle{empty}
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex}
\def\DBKcover{
\ifthenelse{\equal{\DBKedition}{}}{\def\edhead{}}{\def\edhead{Ed. \DBKedition}}
% interligne double
\setlength{\oldbaselineskip}{\baselineskip}
\setlength{\baselineskip}{2\oldbaselineskip}
\sffamily
%%\hfill\includegraphics[width=0.15\textwidth]{../../images/sipwise-logo}\\[1cm]\hspace*{3cm}
\hfill\includegraphics{../../images/sipwise-logo}\hspace*{1cm}
\definecolor{SipwiseGreen}{HTML}{006600}
\definecolor{SipwiseGray}{HTML}{000000}
% not available with LaTeX as provided with >= Debian/wheezy any longer ootb
\@ifundefined{White}{
\definecolor{White}{HTML}{FFFFFF}
}{}
\vspace*{9cm}
\hspace*{-3cm}\colorbox{SipwiseGreen}{
\begin{minipage}[t][1.3cm][t]{1.3\textwidth}
\color{SipwiseGreen}
\hspace*{3cm}\hfill Sipwise GmbH\hspace*{3cm}
\end{minipage}
}
\linebreak[4]
\hspace*{-3cm}\colorbox{SipwiseGray}{
\begin{minipage}[t][6cm][t]{1.3\textwidth}
\color{White}
\vspace*{1cm}
\hspace*{3cm}\hfill\Huge\DBKtitle\hspace*{3cm}\\
\vfill
\hspace*{3cm}\hfill\Large Sipwise GmbH\hspace*{3cm}\\
\ttfamily\hspace*{3cm}\hfill\large <[email protected]>\hspace*{3cm}\\
\vspace*{0.5cm}
\end{minipage}
}
\clearpage
\sffamily
% Format for the other pages
\newpage
\setlength{\baselineskip}{\oldbaselineskip}
% dblatex 0.3-2 (Debian/squeeze) provides DBKcheadfront,
% dblatex 0.3.4-1 (Debian/wheezy) no longer provides DBKcheadfront
\@ifundefined{DBKcheadfront}{
\chead[]{}
}{
\chead[]{\DBKcheadfront}
}
\lfoot[]{}
}
\fancyhf{}
\rhead{\rightmark}
\rfoot{\thepage}
% For DocBook literallayout elements, see `./dblatex/dblatex-readme.txt`.
\usepackage{alltt}
这是我改造后的版本:
%%
%% This style is derived from the docbook one.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{asciidoc}[2008/06/05 AsciiDoc DocBook Style]
\RequirePackageWithOptions{docbook}
\@ifpackageloaded{xcolor}{
\PassOptionsToPackage{usenames,dvipsnames, fancyhdr}{xcolor}
}{
\usepackage[usenames,dvipsnames, fancyhdr]{xcolor}
}
\setlength{\parindent}{2em}
\linespread{1.3}
\thispagestyle{empty}
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex}
\def\DBKcover{
\ifthenelse{\equal{\DBKedition}{}}{\def\edhead{}}{\def\edhead{Ed. \DBKedition}}
% interligne double
\setlength{\oldbaselineskip}{\baselineskip}
\setlength{\baselineskip}{2\oldbaselineskip}
\sffamily
%%\hfill\includegraphics[width=0.15\textwidth]{../../images/sipwise-logo}\\[1cm]\hspace*{3cm}
\hfill\includegraphics{../../images/sipwise-logo}\hspace*{1cm}
\definecolor{SipwiseGreen}{HTML}{006600}
\definecolor{SipwiseGray}{HTML}{000000}
% not available with LaTeX as provided with >= Debian/wheezy any longer ootb
\@ifundefined{White}{
\definecolor{White}{HTML}{FFFFFF}
}{}
\vspace*{9cm}
\hspace*{-3cm}\colorbox{SipwiseGreen}{
\begin{minipage}[t][1.3cm][t]{1.3\textwidth}
\color{SipwiseGreen}
\hspace*{3cm}\hfill Sipwise GmbH\hspace*{3cm}
\end{minipage}
}
\linebreak[4]
\hspace*{-3cm}\colorbox{SipwiseGray}{
\begin{minipage}[t][6cm][t]{1.3\textwidth}
\color{White}
\vspace*{1cm}
\hspace*{3cm}\hfill\Huge\DBKtitle\hspace*{3cm}\\
\vfill
\hspace*{3cm}\hfill\Large Sipwise GmbH\hspace*{3cm}\\
\ttfamily\hspace*{3cm}\hfill\large <[email protected]>\hspace*{3cm}\\
\vspace*{0.5cm}
\end{minipage}
}
\clearpage
\sffamily
% Format for the other pages
\newpage
\setlength{\baselineskip}{\oldbaselineskip}
% dblatex 0.3-2 (Debian/squeeze) provides DBKcheadfront,
% dblatex 0.3.4-1 (Debian/wheezy) no longer provides DBKcheadfront
\@ifundefined{DBKcheadfront}{
\chead[]{}
}{
\chead[]{\DBKcheadfront}
}
\lfoot[]{}
}
\fancyhdr{}
\pagestyle{fancy}
\fancyhf{}
\lhead{
\includegraphics{logo_header.png}}
\rfoot{\thepage}
% For DocBook literallayout elements, see `./dblatex/dblatex-readme.txt`.
\usepackage{alltt}
谢谢 :)
答案1
试试这个:(这是一个文档示例,而不是样式文件)
\documentclass{report}
\usepackage{fancyhdr}
\usepackage[demo]{graphicx}
\pagestyle{fancy}
\lhead{\begin{picture}(0,0)
{\includegraphics[height=0.6cm,width=0.6cm]{images/logo.png}}
\end{picture}}
\rhead{\sf{\thepage}}
\begin{document}
a
\end{document}
来自 fancyhdr 手册:
为了不干扰正常的标题布局,我们将文本放在零尺寸的图片中。通常,这是将内容放置在页面上固定位置的最佳方法。然后,您也可以使用正常标题。另请参阅第 21 节,了解此技术的另一个示例