1

MWE

\documentclass[a4paper,11pt,twoside]{article}
{
Template Source Code
}
\begin{document}
\duty= Soldering         % Duty Title
\pername= Me             % Personnel Name Title
\department= Storehouse  % Department Title
Bla... Bla...
\newpage
\duty= Disassembly       % Duty Title
\pername= You            % Personnel Name Title
\department= Storehouse  % Department Title

Bla... Bla...
\newpage
...
\end{document}

I want to do picture in below. But I could not. Content of Duty, Personnel Name and Department cells may be different in every page. Anyway, Page Number automatic. The next page will variables reset every \newpage is added. I'm waiting for your helps.

enter image description here

Partially My Solve:

\documentclass[a4paper,11pt]{article}
\usepackage[left=1.5cm,right=1.5cm,top=3cm,bottom=1.5cm,marginparwidth=0cm,marginparsep=0cm,outer=2cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{calc}
\usepackage[absolute]{textpos}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\fancyhead[RO,RE,LO,LE]{\textbf{{
\begin{textblock*}{5cm}(1.5cm,1.5cm)\begin{minipage}{5cm}Duty: \end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(15cm,1.5cm)\begin{minipage}{5cm}Page Number: \thepage\ / \pageref{LastPage}\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(1.5cm,27.5cm)\begin{minipage}{5cm}Personnel Name: \end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(10cm,27.5cm)\begin{minipage}{5cm}Date:\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(15cm,27.5cm)\begin{minipage}{5cm}Department:\end{minipage}\end{textblock*}
}}}

\begin{document}

\begin{textblock*}{5cm}(3cm-.6cm,1.5cm)\begin{minipage}{5cm}Soldering\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(1.5cm-.6cm,28cm)\begin{minipage}{5cm}Me\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(10cm-.6cm,28cm)\begin{minipage}{5cm}Date\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(15cm-.6cm,28cm)\begin{minipage}{5cm}Storehouse\end{minipage}\end{textblock*}

\lipsum[1-5]

\newpage

\begin{textblock*}{5cm}(3cm-.6cm,1.5cm)\begin{minipage}{5cm}Disassembly\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(1.5cm-.6cm,28cm)\begin{minipage}{5cm}You\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(10cm-.6cm,28cm)\begin{minipage}{5cm}Date\end{minipage}\end{textblock*}
\begin{textblock*}{5cm}(15cm-.6cm,28cm)\begin{minipage}{5cm}Storehouse\end{minipage}\end{textblock*}

\lipsum[1-5]

\end{document}

enter image description here

ADDED SITUATION*

While I added/changed \lhead{\includegraphics[height=1cm]{example-image-a}\bf{Duty: \it\Theduty}}

There is no space in Page One.

enter image description here

But there is a space in Page Two, Three ... . That is a normal. How fix it? enter image description here

Added to Zarko's answer...

...
\checkoddpage 
\ifoddpage
\node (f1) [NL,wt=181,ht=287,
        above right=5mm and 20mm of current page.south west] {};% <-- frame anchor
\draw   (f1.west) -- + (-1,0);
\else
\node (f1) [NL,wt=181,ht=287,
        above right=5mm and 12mm of current page.south west] {};% <--     frame anchor
\draw   (f1.east) -- + (1,0);
 \fi 
...
Özgür
  • 3,270

3 Answers3

4

Maybe something like?

\documentclass[a4paper,11pt]{article}

\usepackage[left=1.5cm,right=1.5cm,top=3cm,bottom=1.5cm,marginparwidth=0cm,marginparsep=0cm,outer=2cm]{geometry}

\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\newcommand{\Theduty}{}
\newcommand{\duty}[1]{\renewcommand{\Theduty}{#1}}
\newcommand{\Thepername}{}
\newcommand{\pername}[1]{\renewcommand{\Thepername}{#1}}
\newcommand{\Thedepartment}{}
\newcommand{\department}[1]{\renewcommand{\Thedepartment}{#1}}

\lhead{Duty: \Theduty}
\chead{}
\rhead{Page Number: \thepage\ / \pageref{LastPage}}
\lfoot{Personnel Name: \Thepername}
\cfoot{Date: \today}
\rfoot{Department: \Thedepartment}

\setlength{\headheight}{13.6pt}

\begin{document}

\duty{Soldering}         % Duty Title
\pername{Me}             % Personnel Name Title
\department{Storehouse}  % Department Title

\lipsum[1-5]

\newpage
\duty{Disassembly}       % Duty Title
\pername{You}            % Personnel Name Title
\department{Storehouse}  % Department Title

\lipsum[1-5]

\end{document}

enter image description here


EDIT

\documentclass[a4paper,11pt]{article}

\usepackage[left=1.5cm,right=1.5cm,top=3cm,bottom=1.5cm,marginparwidth=0cm,marginparsep=0cm,outer=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\newcommand{\Theduty}{}
\newcommand{\duty}[1]{\renewcommand{\Theduty}{#1}}
\newcommand{\Thepername}{}
\newcommand{\pername}[1]{\renewcommand{\Thepername}{#1}}
\newcommand{\Thedepartment}{}
\newcommand{\department}[1]{\renewcommand{\Thedepartment}{#1}}

%\lhead{Duty: \Theduty} %<-- 
\lhead{\includegraphics[height=1cm]{example-image-a} Duty: \Theduty}
\chead{}
\rhead{Page Number: \thepage\ / \pageref{LastPage}}
\lfoot{Personnel Name: \Thepername}
\cfoot{Date: \today}
\rfoot{Department: \Thedepartment}

\setlength{\headheight}{33pt}

\begin{document}

\duty{Soldering}         % Duty Title
\pername{Me}             % Personnel Name Title
\department{Storehouse}  % Department Title
\lipsum[1-5]
\newpage
\duty{Disassembly}       % Duty Title
\pername{You}            % Personnel Name Title
\department{Storehouse}  % Department Title
\lipsum[1-5]

\end{document}
4

Here is a solution, which does pretty much what you want.

It uses TikZ for the the graphics and scrlayer-scrpage to get the frame into a page style. You can adapt the distance between text and frame and the height for head and foot (here they are always the same height).

Note: the frame is drawn into the margin, therefore the latter will appear to be smaller then set. Add \fsep to get the desired margin.

\documentclass[a4paper,11pt]{report}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum}

% distance from text to frame
\newlength{\fsep}
\setlength{\fsep}{20pt}
% height of head and foot
\newlength{\hfheight}
\setlength{\hfheight}{2\baselineskip}

\geometry{margin=2cm, % can be adapted, real margin is 2cm-\fsep
  % it is possible to write margin=\dimexpr2cm+\fsep to get exact margin
  % next line needed for the way the frame is defined
  includehead,includefoot,headheight=\hfheight,footskip=\hfheight,headsep=0pt
}

\makeatletter
\newcommand*{\@duty}{}
\newcommand*{\duty}[1]{\def\@duty{#1}}
\newcommand*{\@pername}{}
\newcommand*{\pername}[1]{\def\@pername{#1}}
\newcommand*{\@department}{}
\newcommand*{\department}[1]{\def\@department{#1}}

\setkomafont{pageheadfoot}{\normalcolor}

\newlength{\hfdepth}
\setlength{\hfdepth}{0pt}

\tikzset{%
  hfnode/.style={%
    draw,outer sep=0pt,inner xsep=\fsep,
    minimum height=\hfheight,
    text depth=\hfdepth,
    align=left
  },
  headnodeleft/.style={hfnode,
    anchor=south west,
    minimum width=0.6\textwidth+\fsep,
    text width=0.6\textwidth-\fsep
  },
  headnoderight/.style={hfnode,
    anchor=south east,
    minimum width=0.4\textwidth+\fsep,
    text width=0.4\textwidth-\fsep
  },
  footnodeleft/.style={hfnode,
    anchor=north west,
    minimum width=0.6\textwidth+\fsep,
    text width=0.6\textwidth-\fsep
  },
  footnoderight/.style={hfnode,
    anchor=north east,
    minimum width=0.4\textwidth+\fsep,
    text width=0.4\textwidth-\fsep
  }
}

\DeclareNewLayer[%
  textarea,background,
  contents={%
    \tikz{%
      \useasboundingbox(0,0)rectangle(\layerwidth,\layerheight);
      \draw(-\fsep,-\fsep)rectangle(\layerwidth+\fsep,\layerheight+\fsep);
      % note: \hfill can be replaced by a space or e.g. \quad
      \node[headnodeleft] at (-\fsep,\layerheight+\fsep) {\normalfont
        \usekomafont{pageheadfoot}\usekomafont{pagehead}Duty:\hfill\@duty};
      \node[headnoderight] at (\layerwidth+\fsep,\layerheight+\fsep) {\normalfont
        \usekomafont{pageheadfoot}\usekomafont{pagehead}Page Number:\hfill\pagemark};
      \node[footnodeleft] at (-\fsep,-\fsep) {\normalfont
        \usekomafont{pageheadfoot}\usekomafont{pagefoot}Personal Name:\hfill\@pername};
      \node[footnoderight] at (\layerwidth+\fsep,-\fsep) {\normalfont
        \usekomafont{pageheadfoot}\usekomafont{pagefoot}Department:\hfill\@department};
    }%
  }%
]{reportframe}

\DeclareNewPageStyleByLayers{reportframe}{reportframe}
\pagestyle{reportframe}
\makeatother

\begin{document}
\duty{Soldering}         % Duty Title
\pername{Me}             % Personnel Name Title
\department{Storehouse}  % Department Title
\noindent
\lipsum[1]

\vfill\noindent
\lipsum[2]

\newpage
\duty{Disassembly}       % Duty Title
\pername{You}            % Personnel Name Title
\department{Storehouse}  % Department Title
\noindent
\lipsum[1]

\vfill\noindent
\lipsum[2]
\end{document}
Mike
  • 8,664
4

edit: meanwhile i found the way how to avoid limitation of this solution to only one page. with use package everypage and slightly rearranged and simplified code in the first mwe now the "duty" can have any number of pages:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{
                babel,
                backgrounds,
                calc,
                positioning,
                }
\usepackage[showframe,
            a4paper,
            ignoreall,
            hmargin={25mm,10mm},%
            vmargin={20mm,20mm}%
            ]{geometry}
\usepackage{tabularx}
\usepackage{lastpage}
\usepackage{everypage}

\usepackage{lipsum}

%---------------------------------------------------------------%
\newcounter{okvir}
\newsavebox{\name}
\newsavebox{\duty}
\newsavebox{\school}

\newcommand{\okvir}[3]{%
\clearpage
    \sbox{\name}{#1}
    \sbox{\duty}{#2}
    \sbox{\school}{#3}
\noindent
%    \setcounter{page}{1} % use in the case when each duty should start with page number 1
\AddEverypageHook{
    \begin{tikzpicture}[remember picture, overlay,
    node distance=0mm,
NL/.style = {draw, line width=0.7mm,
             inner xsep=2mm, inner ysep=0mm, outer sep=0mm,
             font=\bfseries\sffamily,
             align=left},
wt/.style = {text width=##1 mm},
ht/.style = {minimum height=##1 mm}
                    ]
\node (f1) [NL,wt=181,ht=287,
            above right=5mm and 20mm of current page.south west] {};% <-- frame anchor
\node (f2) [NL,wt=148,ht=10,
            below right=of f1.north west] {Duty:~\usebox{\duty}};%\
\node (f3) [NL,wt=29,ht=10,
            right=of f2] {page \thepage~of~\pageref{LastPage}};
\node (f4) [NL,wt=88,ht=10,
            above right=of f1.south west] {Personal name:~\usebox{\name}};%
\node (f5) [NL,wt=89,ht=10,
            right=of f4]  {Department:~\usebox{\school}};%
\draw   (f1.west) -- + (-1,0);
    \end{tikzpicture}
    }% end of every page hook
                    }% end of newcommand
%---------------------------------------------------------------%

\begin{document}
\pagestyle{empty}
%---------------------------------------------------------------%
\okvir{NAME}{DUTY}{11th SCHOOL}
\lipsum\lipsum\lipsum\lipsum[1]

%---------------------------------------------------------------%
\okvir{Joe Doe}{Joe Doe task}{department unknown}
\lipsum\lipsum

\end{document}

mwe still had to be compiled at least twice.

in cases, that each task, i.e. duty had to start with page number 1, then only you need to remove % on beginning of the line \setcounter{page}{1} (see mwe)

enter image description here enter image description here enter image description here enter image description here

addendum: for two side documents the "okvir" (frame) had to be aware if page number is odd or even. for this you need add to it simple test with \isodd:

\newcommand{\okvir}[3]{%
\cleardoublepage    % new tasks starts on odd pages
% \clearpage        % new tasks starts on any pages
    \sbox{\name}{#1}
    \sbox{\duty}{#2}
    \sbox{\school}{#3}
\noindent
%    \setcounter{page}{1} % use in the case when each duty should start with page number 1
\AddEverypageHook{
    \begin{tikzpicture}[remember picture, overlay,
    node distance=0mm,
NL/.style = {draw, line width=0.7mm,
             inner xsep=2mm, inner ysep=0mm, outer sep=0mm,
             font=\bfseries\sffamily,
             align=left},
wt/.style = {text width=##1 mm},
ht/.style = {minimum height=##1 mm}
                    ]
\ifodd\value{page}
\node (f1) [NL,wt=181,ht=287,
            above right=5mm and 20mm of current page.south west] {};% <-- odd frame anchor
\else
\node (f1) [NL,wt=181,ht=287,
            above right=5mm and 5mm of current page.south west] {};% <-- even  frame anchor
\fi            
\node (f2) [NL,wt=148,ht=10,
            below right=of f1.north west] {Duty:~\usebox{\duty}};%\
\node (f3) [NL,wt=29,ht=10,
            right=of f2] {page \thepage~of~\pageref{LastPage}};
\node (f4) [NL,wt=88,ht=10,
            above right=of f1.south west] {Personal name:~\usebox{\name}};%
\node (f5) [NL,wt=89,ht=10,
            right=of f4]  {Department:~\usebox{\school}};%
\draw   (f1.west) -- + (-1,0);
    \end{tikzpicture}
    }% end of every page hook
                    }% end of newcommand

enter image description here

note: code for okvir is not aware if document use option twoside. if you like to have this feature too, please ask new question :).

Zarko
  • 296,517