LaTeX 中带有图片、标尺和多行的标题

LaTeX 中带有图片、标尺和多行的标题

我试图找出以下标题方案但没有成功:

_______
|      |  | Text                                        TEXT
| Pic  |  | ________________________________________________
|______|  | Text              TEXT                      TEXT

我使用了 fancyhdr,但我无法弄清楚如何将标尺放在整行上,fancyhdr 允许我将标尺放在 L/C/R 文本下方。此外,我无法创建垂直标尺。对于这张图片,我放弃了。因为我花了很多时间来弄清楚标尺。

我原本想将 myheadings 样式与 markboth 命令结合使用,但是我无法换行,而且 LaTeX 会将所有内容放在一行上,即使尝试使用 \newline 命令等也是如此。

\documentclass{12pt, twoside}{article}
\pagestyle{myheadings}
\pagenumbering{gobble}
\markboth{}{Left text \hfill center text \hfill right text \newline second line left}

\begin{document}
Page 1
\newpage
Page 2
\end{document}

有什么提示吗?我应该从哪里开始?

非常感谢

答案1

这只是一个起点,因为它可能需要根据实际文本进行一些调整。

\documentclass[12pt,twoside]{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{fancyhdr}
\pagenumbering{gobble}

\setlength{\headheight}{39pt}
\fancyhf{}
\fancyhead[LO, RE]{\includegraphics[width=1.5cm]{example-image-a}}
\fancyhead[RO]{%
    \raisebox{2.5ex}{%
        \begin{tabular}{|>{\centering\arraybackslash}p{.84\textwidth}@{}}
            Left text \hfill Right text \\
            \hline
            \rule{0pt}{14pt}Second line left \hfill Center text \hfill Second line right
        \end{tabular}}}
\fancyhead[LE]{%
    \raisebox{2.5ex}{%
        \begin{tabular}{@{}>{\centering\arraybackslash}p{.84\textwidth}|}
            Left text \hfill  Right text \\
            \hline
            \rule{0pt}{14pt}Second line left \hfill Center text \hfill Second line right
        \end{tabular}}}
\renewcommand\headrulewidth{0pt}
\pagestyle{fancy}

\usepackage{mwe}

\begin{document}
Page 1
\blindtext
\newpage
Page 2
\blindtext
\end{document}

第 1 页:

在此处输入图片描述

第2页:

在此处输入图片描述

答案2

抱歉,我花了这么长时间才完成这项工作。不过,由于我刚刚完成了解决方案,因此我会发布它,尽管它可能与 CarLaTeX 的解决方案相似:

\documentclass[twoside]{report}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

% Dummy text
\usepackage{lipsum}
\setlipsumdefault{1-20}     % Make sure we get enough dummy text to fill several pages

\usepackage{calc}
\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}

%% Define variables for the text fields
%% Please note: They resemble the scheme from the fancyhdr documentation,
%%              but we will use only one of the fields from fancyhdr to place the text!

% Set contents of the textfields
\newcommand{\fhtexttl}{Text top left}
\newcommand{\fhtexttr}{Text top right}
\newcommand{\fhtextbl}{Text bottom left}
\newcommand{\fhtextbc}{Text bottom center}
\newcommand{\fhtextbr}{Text bottom right}

% For twoside classes (e.g. book, report}, we need to shuffle things around
% First, define variables for odd pages
\newcommand{\fhoddtl}{\fhtexttl}
\newcommand{\fhoddtr}{\fhtexttr}
\newcommand{\fhoddbl}{\fhtextbl}
\newcommand{\fhoddbc}{\fhtextbc}
\newcommand{\fhoddbr}{\fhtextbr}

% Now, define variables for even pages -- everything is mirrored
\newcommand{\fheventl}{\fhtexttr}
\newcommand{\fheventr}{\fhtexttl}
\newcommand{\fhevenbl}{\fhtextbr}
\newcommand{\fhevenbc}{\fhtextbc}
\newcommand{\fhevenbr}{\fhtextbl}

%% Define the image we use
\newcommand{\fhimage}{example-image-a}
\newsavebox{\fhlogo}

% Set width of image
\newlength{\fhimagewidth}
\setlength{\fhimagewidth}{2cm}

\sbox{\fhlogo}{\includegraphics[width=\fhimagewidth]{\fhimage}}

% Calculate height of image
\newlength{\fhimageheight}
\setlength{\fhimageheight}{\totalheightof{\usebox{\fhlogo}}}

% Set distance between image, vertical line, and the other header field
\newlength{\fhimagesep}
\setlength{\fhimagesep}{\widthof{~}}

% Set width of the vertical line between image and text
\newlength{\fhimagerulewidth}
\setlength{\fhimagerulewidth}{.5pt}

% Calculate width of textfield
\newlength{\fhtextwidth}
\setlength{\fhtextwidth}
          {\textwidth-\fhimagewidth-2\fhimagesep-\fhimagerulewidth}

% Define spacer inserted at begin/end of text lines in textfield
% so the horizontal line extends beyond the textlines
% (Note: '~' is ignored everywhere but at the start of the first line, so we use a \rule here)
\newcommand{\fhtextspacer}{\rule{\fhimagesep}{0pt}}

%% Clear all headers
\fancyhead{}

%% Set up headers for right (odd pages)
% Logo
\fancyhead[LO]{%
    \usebox{\fhlogo}%
    \rule{\fhimagesep}{0pt}%
    \rule{\fhimagerulewidth}{\fhimageheight}%
    \rule{\fhimagesep}{0pt}%
}

% Text
\fancyhead[RO]{%
    \parbox[b][\fhimageheight][c]{\fhtextwidth}
              {%
                \fhtextspacer\fhoddtl\hfill\fhoddtr\fhtextspacer\\[-.5\baselineskip]%
                \rule{\fhtextwidth}{.5pt}\\%
                \fhtextspacer\fhoddbl\hfill\fhoddbc\hfill\fhoddbr\fhtextspacer%
              }%
}


%% Set up headers for left (even pages)
% Logo
\fancyhead[RE]{%
    \rule{\fhimagesep}{0pt}%
    \rule{\fhimagerulewidth}{\fhimageheight}%
    \rule{\fhimagesep}{0pt}%
    \usebox{\fhlogo}%
}

% Text
\fancyhead[LE]{%
    \parbox[b][\fhimageheight][c]{\fhtextwidth}
              {%
                \fhtextspacer\fheventl\hfill\fheventr\fhtextspacer\\[-.5\baselineskip]%
                \rule{\fhtextwidth}{.5pt}\\%
                \fhtextspacer\fhevenbl\hfill\fhevenbc\hfill\fhevenbr\fhtextspacer%
              }%
}

% Set this to the header height actually needed
\setlength{\headheight}{48pt}

% Uncomment the following line if you don't want to have a line below the complete header!
%\renewcommand{\headrulewidth}{0pt}

% BEGIN THE DOCUMENT
\begin{document}
\chapter{Test}
\lipsum
\end{document}

相关内容