How do I add an image in the upper, left-hand corner using TikZ and graphicx
You can use the background
package which internally relies on tikz
to place either an imported graphic logo or a logo created with a tikzpicture
on each page or on selected pages:
The code below places the image on each page. However, if you only want to place the logo on some of the pages you would simply load the package with the some
option:
\usepackage[some]{background}
and then issue the \BgThispage
on the pages where you wanted the logo. An example of including the image on specific pages (ex, 2, 3, and 6) can be found in Image on top specified page.
Note
- Need at least two runs to see the logo.
Code:
\documentclass[12pt]{article}
\usepackage[demo]{graphicx}
\usepackage[all]{background}
\usepackage{lipsum}
\usepackage{showframe}
\usepackage{tikz}
\newcommand{\MyGraphicLogo}{% For imported graphic logo
\begin{tikzpicture}[remember picture,overlay,yshift=-2cm, xshift=2cm]
\node at (0,0) {\includegraphics[width=2cm,height=2cm]{foo}};
\end{tikzpicture}
}
\newcommand{\MyTikzLogo}{% For a logo drawn with TikZ
\begin{tikzpicture}[remember picture,overlay,yshift=-1cm, xshift=1cm]
\draw [cyan,fill=yellow] (0cm,0cm)
-- (2cm, 0cm)
-- (2cm, -2cm)
-- (0cm, -2cm)
-- cycle;
\end{tikzpicture}
}
%\SetBgContents{\MyGraphicLogo}% Select included image
\SetBgContents{\MyTikzLogo}% Select tikz picture
\SetBgPosition{current page.north west}% Select location
\SetBgOpacity{1.0}% Select opacity
\SetBgAngle{0.0}% Select roation of logo
\SetBgScale{1.0}% Select scale factor of logo
\begin{document}
\section*{Lorem Ipsum}
\lipsum[1-12]
\end{document}
While tikz
is powerful, eso-pic
can also be used to perform this via \AddToShipoutPictureBG
(or \AddToShipoutPictureFG
):
\documentclass[12pt]{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage{eso-pic}% http://ctan.org/pkg/eso-pic
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\AddToShipoutPictureBG{%
\AtPageUpperLeft{\raisebox{-\height}{\includegraphics[width=1.5in]{tiger}}}%
}
\begin{document}
\section*{Lorem Ipsum}
\lipsum[1-50]
\end{document}