1

I'm dealing with the graphic part of a document which I need to fill with text. In particular I need to have a header where to put some general information and the document text simply boxed.

Depending on the text verbosity, the document can be one page or x pages. In this last case, starting from page 2, I don't want anymore the header, but only the text boxed.

I tried to figure how to obtain the boxed text and I discovered Tikz. But I have some problems by defining the margins of the box and then the text behavior for the page after the first. The top margin seems to disappear, I don't understand why. I tried a lot of solutions, using \fbox or using \trimbox{} and \adjustebox, but I didn't find a solution yet.

Secondly, I can't make the header disappear after the first page. I tried with \clearpage and \thispagestyle{empty} but they remove margins and page numbering also.

I a MWE to show what I did until now:

\documentclass[a4paper]{article}
\usepackage[all]{background}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage[sfdefault, light]{roboto}
\usepackage{adjustbox}

\usepackage{geometry} 
\geometry{left=80pt, right=80pt, top=65pt}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}

\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{\footnotesize Page \thepage\ of \pageref{LastPage}}
\chead{{\large \textsc{My Name IS}}\\ \vspace{3pt} {\small My Work IS -- My Specialisation IS}\\ My Cell. IS -- My ID IS}
\renewcommand{\headrulewidth}{0pt}

\usepackage{lettrine}
\usepackage{fix-cm}

\newcommand{\Frame}{
\trimbox{10cm 10cm 10cm 5cm}{
\begin{tikzpicture}[every node/.style={inner sep=10,outer sep=10},overlay, remember picture]
\draw [line width=1mm]
    ($ (current page.north west) + (1cm,-3cm) $)
    rectangle
    ($ (current page.south east) + (-1cm,1cm) $);
\end{tikzpicture}
}
}

\SetBgContents{\Frame}
\SetBgOpacity{100}
\SetBgColor{black}
\SetBgAngle{0}
\SetBgScale{1}

\begin{document}
\vspace*{50pt}

 \lipsum[1-19]  

\end{document}

Thank you for your time and help! R.

  • see tcolorbox package, maybe can help you – Zarko Jul 30 '17 at 18:34
  • regarding making the headers disappear, try putting \pagestyle{empty} right in the file, and after the pages with tikz content are safely finished, probably after a \newpage, add \pagestyle{headers} to restore them. (not tested.) – barbara beeton Jul 30 '17 at 19:12
  • You realize the 65pt is less then 3cm. Or did you mean 1cm? – John Kormylo Jul 30 '17 at 20:47
  • @Zarko thank you for your answer. I'm gonna have a look at tcolorbox and try to make it useful for my needs. @barbarabeeton thank you for your answer. I tried putting \pagestyle{empty} but after a new page the style comes back. @JohnKormylo thank you for your answer. If I understood well, you mean that the border of the top frame is lower than the other three isn't it? It's exactly what I want. – user51937 Jul 31 '17 at 7:20
0

I prefer to use everypage with tikzpagenodes for headers etc.

\documentclass[a4paper]{article}
\usepackage[all]{background}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{lipsum}
%\usepackage[sfdefault, light]{roboto}

\usepackage{geometry} 
\geometry{left=80pt, right=80pt, top=65pt}
%\usepackage[T1]{fontenc} 
%\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{lettrine}
\usepackage{fix-cm}

\pagestyle{empty}

\usepackage{everypage}
\AddEverypageHook{\ifnum\value{page}=1
\begin{tikzpicture}[every node/.style={inner sep=0pt},overlay, remember picture]
  \node[above] at (current page footer area.south) {\footnotesize Page \thepage\ of \pageref{LastPage}};
  \node[below] at (current page header area.north)
  {\begin{tabular}{c}
    {\large \textsc{My Name IS}}\\[3pt]
    {\small My Work IS -- My Specialisation IS}\\
    My Cell. IS -- My ID IS
  \end{tabular}};
  \end{tikzpicture}%
\else
  \begin{tikzpicture}[overlay, remember picture]
  \node[above] at (current page footer area.south) {\footnotesize Page \thepage\ of \pageref{LastPage}};
  \draw [line width=1mm]
    ($ (current page.north west) + (1cm,-1cm) $)
    rectangle
    ($ (current page.south east) + (-1cm,1cm) $);
  \end{tikzpicture}%
\fi}

\begin{document}
\vspace*{50pt}

 \lipsum[1-19]  

\end{document}
  • Dear @JohnKormylo, thank you for your answer! It works perfectly by using a if-then-else cicle. There's just a problem, which I think is related with the 65pt question you asked me before. The problem is that I want the tikz border of the first page, only the first, lower, because I need to insert My Data IS, etc.. In your excellent solution, in the first page there isn't any tikz border.. Anyway, I tried to understand the code you proposed and I find a solution by inserting the \draw code with (1cm,-3cm) even for the first page and it works! Thank you very much! R. – user51937 Jul 31 '17 at 7:28
  • How to insert an image right in a comment? I would show the final result, for future needing. ibb.co/bu5wS5 – user51937 Jul 31 '17 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.