Skip to main content
major tweak
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only }% end of \AtBeginDocument \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox\parbox[t]{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only }% end of \AtBeginDocument \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only }% end of \AtBeginDocument \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox[t]{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
minor tweak
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only }% end of \AtBeginDocument  \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} }% end of \AtBeginDocument \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} }% end of \AtBeginDocument \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only }% end of \AtBeginDocument  \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
oops
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\makebox[\textwidth]\parbox{\myfooter\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} }% end of \AtBeginDocument \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\makebox[\textwidth]{\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} }% end of \AtBeginDocument \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
\documentclass{exam} \usepackage[fontsize = 14pt]{scrextend} \usepackage{lipsum} \usepackage[xparse,breakable,raster,skins]{tcolorbox} \tcbuselibrary{fitting} \pagestyle{headandfoot} \newcommand{\myfooter}{% \iflastpage{\raisebox{\dimexpr \height+\depth+5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \newcommand\headerBody{% \begin{tcbitemize}[ raster valign = bottom, valign = bottom, raster columns = 2, blankest, raster after skip = 1ex, ] \tcboxfit[height = 3em, add to width = 2cm, halign = flush left,height=3em] {University\\Faculty\\Program} \tcbitem[add to width = -2cm, halign = flush right,] \includegraphics[height = 3em]{example-image} \end{tcbitemize} % \hrule % \begin{tcbraster}[ raster columns = 3, valign = center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit{Final\\Semester} \tcboxfit[before upper*=\centering]{Course Code} \tcboxfit[halign = flush right]{\textbf{date}\\\textbf{time}} \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest ] \tcboxfit[interior engine = standard,colback = gray!20, top = 1ex, bottom = 1ex,]{\textbf{Course}}% \end{tcbraster} % \hrule % \begin{tcbraster}[ raster columns = 1, valign = center, halign = flush center, raster before skip = 1ex, raster after skip = 1ex, blankest, ] \tcboxfit[top = 1ex, bottom = 1ex,]{This exam contains.}% \end{tcbraster} % \hrule% } \usepackage[a4paper, includehead, headheight=0pt,% will be reset \AtBeginDocument headsep=0pt, includefoot, foot=0mm, bottom=20mm, top=0mm, showframe]{geometry} \newsavebox{\headerbox} \AtBeginDocument{\savebox{\headerbox}{\begin{minipage}{\textwidth} \begin{tcbraster}[ fit algorithm=hybrid*, raster equal height = rows, raster halign = center, raster valign = center, raster equal skip = 0mm, raster force size = false, boxsep = 0pt, beforeafter skip = 0pt, leftright skip = 0pt, raster right skip = 0pt, raster left skip = 0pt, raster before skip = 0pt, raster after skip = 0pt, nobeforeafter, height = 2em, raster rows=4, ]% \headerBody% \end{tcbraster}% \end{minipage}} \geometry{headheight = {\dimexpr \ht\headerbox+\dp\headerbox}} \enlargethispage{-\headheight}% first page only \firstpageheader{}{\usebox\headerbox}{} \runningheader{}{\usebox\headerbox}{} \AddToHookNext{shipout/background}{\put({\dimexpr 1in+\oddsidemargin},{\dimexpr 20mm-\paperheight-\baselineskip})% {\parbox{\textwidth}{\centering\myfooter}}}% first page footer %\firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} }% end of \AtBeginDocument \ExplSyntaxOn \keys_define:nn { diaa / answers } { d .dim_set:N = \l__diaa_answers_distance_dim, t .dim_set:N = \l__diaa_answers_thickness_dim, c .tl_set:N = \l__diaa_answers_color_tl, d .initial:n = 10mm, t .initial:n = 0.2pt, c .initial:n = gray, } \NewTColorBox { fillAnswerRules } { O{} } { height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners, boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1 } \NewDocumentCommand{\FillAnswerRules}{O{}} {\stepcounter{page}\iflastpage{\enlargethispage{-1cm}}{}\addtocounter{page}{-1}% does not affect footer location \begin{fillAnswerRules} \keys_set:nn { diaa / answers } { #1 } \leaders \hbox:n { \makebox[\textwidth][s] { \color{\l__diaa_answers_color_tl} \vrule width 0pt height 0.5\l__diaa_answers_distance_dim depth 0.5\l__diaa_answers_distance_dim \leaders \hrule height \l__diaa_answers_thickness_dim \hfill } }\vfill \null \end{fillAnswerRules} } \ExplSyntaxOff \begin{document} \begin{questions} \question \begin{parts} \part \lipsum[1-2] \FillAnswerRules \FillAnswerRules \part \lipsum[1] \FillAnswerRules \end{parts} \end{questions} \end{document} 
minor correction
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
Loading
deleted 5274 characters in body
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
Loading
added comment
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
Loading
added 5258 characters in body
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
Loading
Source Link
John Kormylo
  • 89.1k
  • 3
  • 57
  • 131
Loading