平均能量损失
\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}
我想在下面做图片。但我做不到。每页的职责、人员姓名和部门单元格的内容可能不同。无论如何,页码是自动的。下一页将在每个\newpage
添加时重置变量。我在等待你的帮助。
部分我的解决方案:
\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}
添加的情况*
当我添加/更改\lhead{\includegraphics[height=1cm]{example-image-a}\bf{Duty: \it\Theduty}}
第一页没有空间。
添加到 Zarko 的答案......
...
\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
...
答案1
编辑:
同时,我找到了如何避免将此解决方案限制在一页的方法。everypage
首先使用包并稍微重新排列和简化代码姆韦现在“职责”可以有任意数量的页面:
\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}
姆韦仍然需要至少编译两次。
如果每项任务(即职责)必须从第 1 页开始,则只需删除行首的 % 即可\setcounter{page}{1}
(请参阅姆韦)
附录:
对于双面文档,“okvir”(框架)必须知道页码是奇数还是偶数。为此,您需要添加简单的测试\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
笔记:代码okvir
不知道文档是否使用选项twoside
。如果您也喜欢此功能,请提出新问题:)。
答案2
这是一个解决方案,它几乎可以满足您的要求。
它使用 TikZ 来制作图形,scrlayer-scrpage
并将框架变成页面样式。您可以调整文本和框架之间的距离以及头部和脚部的高度(这里它们始终是相同的高度)。
注意:框架被绘制到边距中,因此后者看起来会比设置的要小。添加\fsep
以获得所需的边距。
\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}
答案3
也许是类似的东西?
\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}
编辑
\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}