3

I am doing a PHP script to write a .tex file.

Based in this insert a horizontal cut line, I want to "print" many block on one page, and between block I want draw a "cut line".

But I dont want draw a cut line at bottom of page.

The script write:

  • BLOCK
  • LINE
  • BLOCK
  • LINE
  • BLOCK
  • ...

For this example I am using minipage to avoid break the "block" and inserting the cut line between this "blocks"

EDITED now with an cycle method

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pifont}
\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\usepackage{lipsum}  
\usepackage[letterpaper, portrait, tmargin=8mm, bmargin=10mm]{geometry}
\usepackage{pgffor}

\begin{document}
This line its for fix width \\
% JUST REPEAT BLOCK MANY TIMES (NOT REAL BUT WORKS FOR EXAMPLE)
\foreach \n in {1,...,3}{
    % START BLOCK
    \begin{minipage}{\textwidth}
        \textbf{{\large Block Number \n}} \\
        \lipsum[2-4]
    \end{minipage}

    \vspace{\baselineskip}
    \noindent\dotfill\ding{33}\dotfill
    \vspace{\baselineskip}
    % END BLOCK
}
\end{document}

Example Code

As you can see in the image, the cut line it pointless at the end of the page, it does not should to be drawn/inserted

I think it can be solved using something like needspace, but I would not know how to start.

3

After a while reading the package needspace I try to write a command cutline based in needspace.

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage[letterpaper, portrait]{geometry}
\usepackage{pgffor} % For cycle
\usepackage{pifont}
\usepackage{calc}

\makeatletter
    \newcommand{\cutline}[1]{\par \penalty-100\begingroup
        \setlength{\dimen@}{#1+6\baselineskip} % Sum space of block and cutline
        \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
        \ifdim \dimen@>\dimen@ii
            \ifdim \dimen@ii>\z@
                \vfil
            \fi
            \break
        \else
            \vspace{\baselineskip}
            \noindent\dotfill\ding{33}\dotfill
            \vspace{\baselineskip}
        \fi
        \endgroup}
\makeatother

\def\one{1}
\newlength{\blockheight}

\begin{document}

% JUST REPEAT BLOCK MANY TIMES (NOT REAL BUT WORKS FOR EXAMPLE)
\foreach \n in {1,...,20}{
    \def\newblock{ % SET BLOCK DATA
        \begin{minipage}{\textwidth}
            \textbf{{\large Block Number \n}} \\
            \lipsum[4-1]
        \end{minipage}      
    }
    \settoheight\blockheight{\newblock} % GET HEIGHT OF NEXT BLOCK
    \ifnum \n>1 % SKIP FIRST BLOCK
        \cutline{\blockheight} % PRINT CUTLINE OR BREAK BASED ON NEXT BLOCK HEIGHT
    \fi
    \newblock % PRINT BLOCK
}
\end{document}

Result

Result

I want to clarify two things:

  • Obviously in the generation of the .tex will be detected if the block is the first, so as not to insert a cutline.
  • If there is a better proposal, I will accept it.
0

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.