0

I want to compile a tcolorbox environment for each fixed-width page with a header and footer.

If I use the geometry package, the height page must be fixed. For standalone class, the height page can be fixed with the contents, but it not supports the header and footer.

Please help me create an environment with fixed width and as long as their heights, header, and footer.

Thank you very much! enter image description here enter image description here

enter image description here

2
  • standalone class is not valid to produce regular documents with header, footer. It's only to get independent figures or text fragments. And I don't understand the relation with tcolorbox, could you better explain the problem?
    – Ignasi
    Commented May 27, 2021 at 7:10
  • @Ignasi I need to create an environment for rounded rectangles. I am using tikz package to draw these picture by hand. Commented May 27, 2021 at 13:47

4 Answers 4

0

Personally, I would program a few things to solve this problem elegantly.

  1. I would first create a command to create the header:

\newcommand{my_fancy_header}{...}

  1. Then I would create a command to create the footer:

\newcommand{my_fancy_footer}{...}

  1. And finally a custom environment which uses all of those and expands the tcolorbox:

\newenvironment{my_fancy_environment}{\my_fancy_header\begin{tcolorbox}}{\end{tcolorbox}\my_fancy_footer}

3
  • Then the page height is not flexible.I want each picture as a page. Commented May 27, 2021 at 14:08
  • Are you talking about changing the paper size, or are you saying that you want your header and your footer to move in relation to the beginning/end of your tcolorbox?
    – S.Comeau
    Commented May 27, 2021 at 14:12
  • I want both. Now I have idea from your help. I will use standalone with tikz. Commented May 27, 2021 at 14:16
0

May be try something like that:

  \usepackage[left=1.5cm,right=1.5cm,
  top=1.5cm,bottom=2cm,bindingoffset=0cm]{geometry}
0

It's possible to combine a tcbraster inside a incgraph environment to get independent pages with sizes adjusted to their contents.

\documentclass{article}
\usepackage{incgraph}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\tcbset{
headbox/.style={
    sharp corners, notitle, colback=white, colframe=blue!50!green,  
    colupper=blue!50!green, halign=center, top=3mm, bottom=3mm},
footbox/.style={ 
    sharp corners, notitle, colback=white, colframe=blue!50!green, 
    colupper=blue!50!green, halign=center},
textbox/.style={
notitle, colback=white, colframe=blue}
}


\begin{document}
\begin{inctext}[paper=graphics]
\begin{tcbitemize}[raster columns=1]
\tcbitem[headbox] The information of Exam on header
\tcbitem[textbox] \lipsum[1]
\tcbitem[footbox] The school's name
\end{tcbitemize}
\end{inctext}

\begin{inctext}[paper=graphics]
\begin{tcbitemize}[raster columns=1]
\tcbitem[headbox] The information of Exam on header
\tcbitem[textbox] A short question
\tcbitem[footbox] The school's name
\end{tcbitemize}
\end{inctext}

\begin{inctext}[paper=graphics]
\begin{tcbitemize}[raster columns=1]
\tcbitem[headbox] The information of Exam on header
\tcbitem[textbox]  \lipsum[1-5]
\tcbitem[footbox] The school's name
\end{tcbitemize}
\end{inctext}

\end{document}

enter image description here

0

Sorry I have the complete answer and I don't know how to put it inside your's editor.

enter image description here

enter image description here

\documentclass[two pages,12pt]{article}
\usepackage{lastpage}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{color}
\usepackage{fancyhdr} % For headers and footers
\usepackage{geometry}
\geometry{a4paper,total={210mm,297mm},left=20mm,right=20mm,top=30mm,bottom=30mm}
\usepackage[most]{tcolorbox}
\tcbset{colback=white}
\pagestyle{fancy}
\chead{\fbox{\parbox{\dimexpr\linewidth-7pt}{\centering \bf Examen name and type header}}}

\lhead{} % Left header
\rhead{} % Right header
\lfoot{} % Left footer
\cfoot{\fbox{\parbox{\dimexpr\linewidth-7pt}{\bf School footer \hfill Page n.: \thepage\ of \pageref{LastPage}}}}
\rfoot{} % Right footer
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%\renewcommand*\rmdefault{ppl} %Set font

\begin{document}

\thispagestyle{fancy}                                                                 
\begin{tcolorbox}[enhanced, title style={left color=black, right color=white}, title=\bf Short Question - 30 pts, breakable]
    \lipsum[1-2]\\
    \begin{enumerate}
        \item prima domanda
        \item seconda domanda
    \end{enumerate}
\end{tcolorbox}
\newpage               

\begin{tcolorbox}[enhanced, title style={left color=black, right color=white}, title=\bf Long Question - 50 pts, breakable]
    \lipsum[1-2]\\
    \includegraphics[scale=1.5]{graph sinus and cosinus.pdf}\\
    Rispondi alle seguenti domande:
    \begin{enumerate}
        \item dimostrare che $\sin^2 x+\cos^2 x=1$
        \item Disegnare il grafico della funzione $y=\sqrt{\frac{2x-1}{x+3}}$
    \end{enumerate}
    \lipsum[4-7]
\end{tcolorbox} 
\newpage
\begin{tcolorbox}[enhanced, title style={left color=black, right color=white}, title=\bf Shortest Question - 20 pts, breakable]
    \lipsum[1-2]\\
    \begin{enumerate}
        \item prima domanda
        \item seconda domanda
    \end{enumerate}
\end{tcolorbox}   

\end{document}

You must log in to answer this question.

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