0

i use newcommand and one variable is insert different image.

Minimal code:

\documentclass[10pt]{article}
\usepackage{translator, tikz, array}
\usepackage{graphicx}
\usepackage{lipsum}

\newcommand{\pagelayout}[1]{%
\begin{minipage}{30cm}
\begin{tikzpicture}[remember picture,overlay,shift={(current page.north west)}]
\node[anchor=north west,xshift=1cm, yshift=0.0cm]{\includegraphics[height=2cm,width=5cm,angle=0]{example-image-a}};
\end{tikzpicture}
TEXT TEXT TEXT

\end{minipage} 
}

\begin{document}
\pagelayout\\

\lipsum[3-5]
\newpage
\pagelayout\\

\lipsum[1-3]
\end{document}

How can i change image a- image b- image c when i insert \pagelayout (image a, image b,image c)?

Example:

\pagelayout{\includegraphics[height=2cm,width=5cm,angle=0]{\Image\xyz.jpg}}

Thanks

2
  • 1
    Do you want to fix it up to image-c or its going n number?
    – MadyYuvi
    Sep 20, 2019 at 5:35
  • 1
    unrelated but you should remove the \\ after \newpagelayout (you must get warnings about them in the log?) Also you are missing a % after \end{minipage} Sep 20, 2019 at 6:50

1 Answer 1

2

If you need to fix it upto image-c, then the below tags help you:

\documentclass[10pt]{article}
\usepackage{translator, tikz, array}
\usepackage{graphicx}
\usepackage{lipsum}

\newcommand{\pagelayout}[1]{%
\begin{minipage}{30cm}
\begin{tikzpicture}[remember picture,overlay,shift={(current page.north west)}]
\ifnum\value{page}=1
\node[anchor=north west,xshift=1cm, yshift=0.0cm]{\includegraphics[height=2cm,width=5cm,angle=0]{example-image-a}};\fi
\ifnum\value{page}=2
\node[anchor=north west,xshift=1cm, yshift=0.0cm]{\includegraphics[height=2cm,width=5cm,angle=0]{example-image-b}};\fi
\ifnum\value{page}=3
\node[anchor=north west,xshift=1cm, yshift=0.0cm]{\includegraphics[height=2cm,width=5cm,angle=0]{example-image-c}};\fi
\end{tikzpicture}
TEXT TEXT TEXT
\end{minipage} 
}

\begin{document}
\pagelayout\\

\lipsum[3-5]
\newpage
\pagelayout\\

\lipsum[1-3]
\end{document}

EDIT

Figure name was fixed as optional, now you can pass the figure name in the argument:

\documentclass[10pt]{article}
\usepackage{translator, tikz, array}
\usepackage{graphicx}
\usepackage{lipsum}

\newcommand{\pagelayout}[1]{%
\begin{minipage}{30cm}
\begin{tikzpicture}[remember picture,overlay,shift={(current page.north west)}]
\node[anchor=north west,xshift=1cm, yshift=0.0cm]{\includegraphics[height=2cm,width=5cm,angle=0]{#1}};%
\end{tikzpicture}
TEXT TEXT TEXT
\end{minipage} 
}

\begin{document}
\pagelayout{example-image-a}

\lipsum[3-5]
\newpage
\pagelayout{example-image-b}

\lipsum[1-3]
\end{document}
4
  • thank for your answer. Please edit, not always image c follow image b-image a. Example i want to call image zyz: \pagelayout{\includegraphics[height=2cm,width=5cm,angle=0]{\image\xyz.jpg}. Thanks
    – latexforti
    Sep 20, 2019 at 7:15
  • 1
    So you may get the image in any order? Please confirm whether my understanding is correct?
    – MadyYuvi
    Sep 20, 2019 at 7:20
  • Yes, you last said as i want. Thank you
    – latexforti
    Sep 20, 2019 at 7:22
  • 1
    Please check the edited suggestion...
    – MadyYuvi
    Sep 20, 2019 at 7:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .