3

I am trying to make a letterhead using two different logos on a page using latex. I am using the following codes.

\ThisCenterWallPaper{0.3}{logo.png}
\setlength{\wpXoffset}{-6.1cm}
\setlength{\wpYoffset}{12.07cm}

\LRCornerWallPaper{0.3}{LRsealoffset.png}

The idea is to get the two logos to appear on the first page and the second logo to repeat on the subsequent pages. I have gotten this to work so far and I am able to adjust the position of the first logo using \setlength{\wpXoffset} command. However, I am unable to change the position of the second logo. Using the \setlength{\wpXoffset} below the \LRCornerWallPaper does not seem to work. Do you have any ideas or suggestions?

Thanks.

Harry
  • 187

1 Answers1

1

Using a different approach, based on my answer at What are the ways to position things absolutely on the page?, I introduce \atxy{x-pos}{y-pos}{content} to place something on the current page at a specified location, and then \ateveryxy{x-pos}{y-pos}{content} to do the same for all pages from the invocation forward.

\documentclass{article}
\usepackage{everypage}
\usepackage{lipsum,graphicx}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
\newcommand\ateveryxy[3]{%
 \AddEverypageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\begin{document}
\atxy{0in}{0in}{\raisebox{-\height}{\includegraphics[width=2in]{example-image-A}}}
\atxy{6.5in}{0in}{\raisebox{-\height}{\includegraphics[width=2in]{example-image-B}}}
\lipsum[1-6]
\ateveryxy{3.25in}{0in}{\raisebox{-\height}{\includegraphics[width=2in]{example-image-B}}}
\lipsum[7-19]
\end{document}

Page 1

enter image description here

Subsequent pages

enter image description here

  • Thanks Steve. I gave this a shot, however, I ended up geting errors such as "! Undefined control sequence. \atxy #1#2#3->\AddThispageHook {\smash {\hspace *{\dimexpr -\PageLeftMargin ... l.106 ...}{\includegraphics[width=2in]{logo.png}}}

    ? "

    – Harry Apr 03 '15 at 15:36
  • 1
    @Harry \AddThispageHook is part of the everypage package. Did you place \usepackage{everypage} in your preamble? – Steven B. Segletes Apr 03 '15 at 15:39
  • Hi Steve, thanks for pointing this out. I included the everypage package. Now I get this error "! Undefined control sequence. l.94 \atxy {1in}{1in}{\raisebox{-\height}{\includegraphics[width=2in]{logo.png...

    ? "

    – Harry Apr 03 '15 at 15:44
  • @Harry Well, I presumed you already had \usepackage{graphicx} in your code, but depending on what you removed to make room for mine, you want to insure that it is present. – Steven B. Segletes Apr 03 '15 at 15:46
  • Hello Steve. I have \usepackage{graphicx} in my code. I commented out my older wallpaper command and put your code in its place. Thanks for your patience. I am yet to make a lot of progress using Latex – Harry Apr 03 '15 at 15:49
  • @Harry Are you able to create a separate .tex file by copying and pasting my complete code (perhaps changing only the name of the graphic filename), and get it to successfully compile? – Steven B. Segletes Apr 03 '15 at 15:51
  • Hello Steve. I feel rather stupid to confess, but I just realized that I had to remove \lipsum[1-6] and \lipsum[7-19] from the code. The document now compiles fine. Thank you so much for your patience and understanding. – Harry Apr 03 '15 at 15:53
  • 1
    @Harry I should have thought of that. For beginners not yet familiar with lipsum, it may seem like an important part of the solution, when in fact it is just filler text. Glad you resolved it! Welcome to the site. – Steven B. Segletes Apr 03 '15 at 15:55
  • Thanks Steve. I appreciate your help. Everybody in the Tex Community are very friendly, helpful and welcoming. Keep up the nice work! – Harry Apr 03 '15 at 15:56
  • 1
    @Harry I noticed that you have asked 3 questions but have not "accepted" any answers. The way to say thanks to one who provides an answer is to click the uparrow that appears to the left of their answer. Likewise, of the many answers you might receive, the way to signify that one in particular best answers your question is to click the check mark that appears to the left of the answer. – Steven B. Segletes Apr 03 '15 at 15:59
  • I am new to Tex Exchange. I will look up the rules for this site and make sure that I acknowledge people for their contribution. Thank you so much for pointing this out. – Harry Apr 03 '15 at 16:01
  • @ Steven B. Segletes: Would there be a way to fix a part of the text in the same way? Say I need some text on top of my letterhead. At the moment the spacing of the text seems to change depending on the line-spread of the document's text content. It would be great if I could fix my name and contact information just like I fix the position of the logos on the document. Any tips or tricks to get around this? – Harry Apr 24 '15 at 17:14
  • I fixed this using absolute textblock. – Harry Apr 24 '15 at 17:43
  • @Harry The \atxy macro will place "anything", as you perhaps discovered. Thus, passing a \parbox instead of an \includegraphics would do the trick. – Steven B. Segletes Apr 24 '15 at 21:17
  • How can i prevent that they shop up on every page including the title page. I know the example is preventing this but apparently I am doing something wrong. – Stücke Jun 27 '18 at 10:17
  • @Jonas The everypage macros \AddThispageHook and \AddEverypageHook will affect either one or all the subsequent pages, respectively. Those two macros get embodied in my \atxy and \ateveryxy macros which I have provided. So if you don't want something on every page, use \atxy. If you want something on every page after p.7, then invoke \ateveryxy on p.8. Does this help? – Steven B. Segletes Jun 27 '18 at 10:27
  • Thanks for your comment! Unfortunately, it doesn't. I opened your minimal working example and everything works fine. However if I copy paste the example into my actual project, all for sudden the \ateveryxy show up on every page includng the title page where I places \atxy images – Stücke Jun 27 '18 at 11:12
  • 1
    @Jonas I don't understand why that would be, but here is a possible workaround: use a macro in \ateveryxy so that the macro can be redefined to \relax when you don't want it on the page: \begin{document} \atxy{0in}{0in}{\raisebox{-\height}{\includegraphics[width=2in]{example-image-A}}} \atxy{6.5in}{0in}{\raisebox{-\height}{\includegraphics[width=2in]{example-image-B}}} \lipsum[1-6] \def\myepcmd{\raisebox{-\height}{\includegraphics[width=2in]{example-image-B}}} \ateveryxy{3.25in}{0in}{\myepcmd} \lipsum[7-12] \let\myepcmd\relax \lipsum[13-19] \end{document} – Steven B. Segletes Jun 27 '18 at 11:28
  • Works so far but how can I reshow the myepcmd after the \let\relax again? Afterall, I don't want to show the images before the let\lexas as I want to hide them on the title page. Thanks for the support – Stücke Jun 27 '18 at 11:53
  • @Jonas Just redefine \myepcmd (or whatever you are calling it) to something else (for example, an \includegraphics), with \renewcommand or \def. – Steven B. Segletes Jun 27 '18 at 12:00
  • Hm if I get this right I would then have \myepcmd then relax and then \alternative_myepcmd. But that does not really make sense if I want to avoid having images on the first first page (title page) ... because no matter how early in the document I will copy the \myepcmd it will always show up on the first page or not? – Stücke Jun 27 '18 at 12:26
  • @Jonas The effect of an \atxy or \ateveryxy invocation should never affect pages that were typeset prior to its invocation. – Steven B. Segletes Jun 27 '18 at 12:51
  • Got it! :) I guess it had something to do with my \includes's in the beginning – Stücke Jun 27 '18 at 13:04