LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   LaTeX, placing graphics in header (https://www.linuxquestions.org/questions/programming-9/latex-placing-graphics-in-header-722706/)

edgjerp 04-30-2009 08:38 AM

LaTeX, placing graphics in header
 
I am helping with making a songbook in LaTeX. The songs are to be marked with how difficult they are to sing and how challenging the guitar chords. How hard would it be to set up so these "grades" can be changed for each song? The best would be to include a small pictogram (e.g. 5 small guitars, 2 shaded for a "level 2" song). on the top of each page. The book is being written as one main document with the songs as included files.

Is it even possible to include a graphic in the header without going down to plain TeX? The simplest(for writing, testing, and reuse) solution would be to define where to place the graphics in the preamble, and then just place a command in each song that tells the compiler which file to use for that song.

something like this:
Code:


%top of included file
\singability{3}
\playability{2} %this would place the graphic with 2 shaded guitars in the page header
\section{songtitle}

my guess that the fancyhdr package might be part of the solution, but it appears that the commands it uses are all placed in the preamble, am I wrong?

jlinkels 04-30-2009 09:25 AM

It is possible to put a graphics in the header:

Code:

\documentclass[a4paper,10pt]{article}
\usepackage{fancyhdr}
\usepackage[pdftex]{color,graphicx}
\pagestyle{fancy}
\setlength{\headsep}{30mm}
\setlength{\parindent}{0pt}
\setlength{\textheight}{185mm}
\thispagestyle{fancy}
\fancyhf{}
\lhead{}
\chead{}

\rhead{\setlength{\unitlength}{1mm}
\begin{picture}(0,0)
        \put(-40,0){\includegraphics[width=50mm]{/var/www/tx_report/images/rnw_logo.jpg}}
        \put(-80,26){
            \parbox[t]{90mm}{
            \begin{flushright}
            \begin{scriptsize}
            \textsf{
            Kaya Gobernador Debrot 240, Postbus 45, Bonaire, Nederlandse Antillen \\
            T: +599 717 5472, F: +599 717 5427, I: www.rnw.an\\
            }
            \end{scriptsize}
            \end{flushright}
            }
        }
\end{picture}}
\renewcommand{\headrulewidth}{0pt}

\lfoot{
\begin{scriptsize}
\textsf{
This document was generated automatically and typeset with \LaTeXe.\\
}
\end{scriptsize}
}

However, to put a changing graphics in the header is somewhat more complicated. It is stated in the Latex not so short introduction that it can be done using the fancyhdr package as you expected. However, I can't give you example of that, but it should be documented in the fancyhdr package. Hope that helps.

jlinkels

edgjerp 05-01-2009 06:38 AM

I found a solution in the fancyhdr manual, by combining the instructions for how to make a movie in the lower righthand corner with a custom counter and changing \rfoot to rhead, I got a small graphic in the top right corner. the coding was even a lot simpler than your example.

Code:

\newcounter{spill}

\rhead{\setlength{\unitlength}{1mm}
\begin{picture}(0,0)
\put(5,0){\includegraphics[width=20mm]{gitar\thespill.jpg}}
\end{picture}}

to change the picture I just use \setcounter{spill}{n} where n is the new number

Stefan_K 05-20-2009 01:42 PM

graphics in header
 
Hi,

Quote:

Originally Posted by edgjerp (Post 3525819)
Is it even possible to include a graphic in the header without going down to plain TeX?

here's an example showing graphics used in headers: Fancy chapter headings with TikZ. Solutions both for fancyhdr and scrpage2 are shown, using TikZ for graphics. But of course you could use \includegraphics instead, for instance with the textpos package that allows absolute positioning of graphics/boxes on the page.

Stefan


--
TeXblog.net


All times are GMT -5. The time now is 08:22 AM.