我想删除橙色线和蓝色框之间的白色间隙。另外,有没有一种“更干净”的方法来绘制蓝色框?
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{tikz}
\definecolor{prussianblue}{rgb}{0.0, 0.19, 0.33}
\renewcommand{\headrulewidth}{0.5mm}
\fancyhead[L]{\noindent%
\tikz{
\draw [fill=prussianblue!80, draw=prussianblue] (0,0) rectangle (\textwidth,0.9);
\node at (1,0.45) {\bf \color{white} Some text};
}}
\fancyhead[R]{
\tikz{
\node at (0,0) {\color{white} .};
\node at (-0.2,0) {\includegraphics[scale=0.1]{lg.png}};
}}
\pagestyle{fancy}
\usepackage{xpatch}
\xpretocmd\headrule{\color{orange}}{}{\PatchFailed}
\usepackage{blindtext}
\begin{document}
\blindtext[3]
\end{document}
答案1
如果您使用 TiKz,使用 TiKz 在矩形底部绘制线条会更简单 --- 也可以使用 fit 库来绘制矩形 - 我已将其叠加在您的图像上仅供参考 - 请看一下它是否符合您的要求 - 我认为您已经添加文本和图像 - 现在不需要 xpatch
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{mwe}
\definecolor{prussianblue}{rgb}{0.0, 0.19, 0.33}
\renewcommand{\headrulewidth}{0.5mm}
\fancyhead[L]{\noindent%
\tikz{
\draw [fill=prussianblue!80, draw=prussianblue] (0,0) rectangle (\textwidth,0.9);
\node at (1,0.45) {\bf \color{white} Some text};
}}
\fancyhead[R]{
\tikz{
\node at (0,0) {\color{white} .};
\node at (-0.2,0) {\includegraphics[scale=0.1]{example-image}};
}}
\pagestyle{fancy}
\usepackage{xpatch}
\xpretocmd\headrule{\color{orange}}{}{\PatchFailed}
\usepackage{blindtext}
\begin{document}
\blindtext[3]
\begin{tikzpicture}
\node[fit={(-10,0) (6.5,3)}, inner sep=0pt, draw=prussianblue, fill=prussianblue, thick] (rect) {};
\draw[line width=3pt, red] (rect.south east)-- (rect.south west);
\end{tikzpicture}
\end{document}
编辑以回应 OP 评论
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{tikz}
\usetikzlibrary{fit,calc}
\definecolor{prussianblue}{rgb}{0.0, 0.19, 0.33}
\renewcommand{\headrulewidth}{0mm}
\fancyhead[L]{\noindent%
\tikz{
\node[fit={(-10,0) (6.5,1)}, inner sep=0pt, draw=prussianblue,
fill=prussianblue, thick] (rect) {};;
\node at ($(rect.west)+(2,0)$) {\bf \color{white} Some text};
\draw[line width=3pt, red] (rect.south east)-- (rect.south west);
\node at ($(rect.east)+(-1cm,1mm)$) {\includegraphics[scale=0.1]{example-
image}};
}}
\pagestyle{fancy}
\usepackage{blindtext}
\begin{document}
\blindtext[3]
\end{document}