ドキュメントのタイトル ページのヘッダーとフッターに中央揃えの画像を追加しようとしています。これは、ワード プロセッサ プログラムで作成した最初の画像のようになります。
このアイデアを LaTeX で実現するために、2 つの異なる方法を試しました。
最初のものは に基づいていましたscrlayer-scrpage
。次のコードでこのパッケージを使用しました。
\documentclass{article}
\usepackage{scrlayer-scrpage, graphicx}
\pagestyle{scrheadings}
\clearpairofpagestyles
\chead{\includegraphics{Picture1.png}}
\begin{document}
\centering{Title}
\end{document}
このコードとパッケージの結果は、期待どおりではありませんでした。これは、この投稿に添付した 2 番目の画像でも確認できます。画像は左側に寄りすぎています。中央に配置されていません。
そのため、私は 2 番目の方法を試しました。そのためには を使用しましたfancyhdr
。このパッケージでは、次のコードを開発しました。
\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[C]{\includegraphics{Picture1.png}}
\begin{document}
\centering{Title}
\end{document}
3 枚目の写真でわかるように、このパッケージと開発されたコードも、写真の高さが十分でなく、右側に寄りすぎているため、適切なソリューションではありません。
そのため、LaTeX ファイルのヘッダーとフッターに中央揃えの画像を配置するという私のアイデアを実現するための他の解決策があるかどうかを尋ねたいだけです。
編集:
答え1
これは を使用したソリューションです。またはパッケージscrlayer-scrpage
を使用した、よりシンプルなソリューションがあるかもしれません。これの良い点は、このページ スタイルをいつでも適用できることです。多くのクラスや (余白) レイアウトで使用できます。ルーラーは参照用です。background
tikz
geometry
\documentclass[a4paper]{mwart}
\usepackage{scrlayer-scrpage}
\usepackage{graphicx,xcolor}
%\usepackage[margin=2cm,includeheadfoot]{geometry}
\DeclareNewLayer[
background,
topmargin,
% align=t,
height=5cm,
%hoffset=7cm,
%addheight=\headheight,
mode=picture,
contents={\includegraphics[height=5cm]{frog.jpg}}
]{top}
\DeclareNewLayer[
background,
bottommargin,
%addheight=\headheight,
mode=picture,
contents={\includegraphics[height=\layerheight,width=\layerwidth]{example-image-b}}
]{bottom}
\DeclareNewLayer[
background,
%outermargin,
%topmargin,
contents=\layercontentsmeasure
]{measurelayer}
%\defpairofpagestyles[plain.scrheadings]{title}{} %use this if you want plain (bottom number) on 1st page
\defpairofpagestyles{title}{}
\AddLayersToPageStyle{title}{top,bottom,measurelayer}
%\DeclareNewPageStyleByLayers{title}{top,bottom,measurelayer} %an alternative you want to create an empty style
\title{asdf} \author{asdf}
\begin{document}
\maketitle
\thispagestyle{title}
\newpage
\setcounter{page}{1}
asdf
\end{document}