Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to generate random text and if random text = \textheight, break page automatically and start new page with the rest of the text in the same textblock environment. I read many articles, but the biggest problem is with absolute position, which ignores everything except \null\newpage. Help me, please!

I have code:

\documentclass[a4paper]{letter}

%define used packages
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{pagecolor}
\usepackage[absolute,overlay]{textpos}
\usepackage{helvet}
\usepackage{multicol}
\usepackage[left=2cm, top=1.5cm, right=1cm, bottom=2cm, includehead]{geometry}
\usepackage{eso-pic}  

%specify layout settings
\voffset = 0pt
\hoffset = 0pt
\headheight = 45pt
\headsep = 0.5cm
\footskip = 0.5cm
\oddsidemargin = -14pt 
\pagecolor{white}
\setlength\columnsep{38pt}

%define custom colors  
\definecolor{MySpecColor}{RGB}{245,247,246}
\definecolor{MySpecTitleColor}{RGB}{249,206,143}
\definecolor{MySpecHeaderColor}{RGB}{221,130,0}

%create new commands
\newcommand{\parallelcolor}{ %
    \color{black}\small\onehalfspacing
        }
\newcommand{\changecolor}{%
    \color{MySpecTitleColor} 
}
\newcommand{\redefinecolor}{%
    \color{black} 
}
\newcommand{\redefineweight}{%
    \bf
}
\newcommand{\setownstyle}{
%   \rmfamily
    \LARGE\color{black}
}
\newcommand{\setownspecstyle}{
%\rmfamily
\LARGE\color{MySpecHeaderColor}
}

%define renewcommands
\renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}


\AddToShipoutPictureBG{%
 \AtTextLowerLeft{\color{MySpecColor}%
 \rule{\textwidth}{\textheight}}}

%define mainpart of document
\begin{document}
\begin{textblock}{12}(2.2,2.5)
\setownstyle Text\\[0pt]
\setownstyle Text\\[0pt]
\setownspecstyle Text
\begin{spacing}{1.3}
\begin{multicols}{2}{
\parallelcolor Text
\vfill
\columnbreak
\parallelcolor Text
}
\end{multicols}
\begin{spacing}{0.7}
\begin{multicols}{2}{
\parallelcolor Text
\vfill
\columnbreak
\parallelcolor Text
}
\end{multicols}
\end{spacing}
\end{spacing}
\end{textblock}
\end{document}
share|improve this question
1  
Welcome to tex.sx, I edited your question using the {} button so the code section formats correctly (just indenting by four spaces is equivalent) could you please edit the question to add lines at the top showing which document class or further packages you use. I tried article class but got ! Undefined control sequence. l.5 \setownstyle –  David Carlisle Dec 14 '12 at 9:47
    
Thanks for editing the question, but it still doesn't work for me (TeXlive 2012) If you do not get an error about \setownstyle could you check which file does define it and I will attempt to update that package. –  David Carlisle Dec 14 '12 at 12:20
    
Can you explain why you want to use \textblock? –  egreg Dec 14 '12 at 13:36
    
I used \textblock, because my text should be overlay the colored rectangle, which should present in every page. I find \usepackage[absolute,overlay]{textpos}, which solved this problem. Is there another way to do the same? –  Lopes Dec 14 '12 at 14:02
    
@Sveta Sorry, but it's not very clear: there is no colored rectangle. –  egreg Dec 14 '12 at 14:13
add comment

1 Answer

Maybe I am not understanding the question and this is too long for a comment, so I'll leave it temporarily as an answer.

Things seem to work as expected removing the textblock environment, as in the following example (in my example code I deleted some of the packages and settings that were not relevant):

\documentclass[a4paper]{letter}
\usepackage{setspace}
\usepackage{helvet}
\usepackage{multicol}
\usepackage[left=2cm, top=1.5cm, right=1cm, bottom=2cm, includehead]{geometry}
\usepackage{eso-pic}
\usepackage{lipsum}% just to generate text for the example

\setlength\columnsep{38pt}

%define custom colors  
\definecolor{MySpecColor}{RGB}{245,247,246}
\definecolor{MySpecTitleColor}{RGB}{249,206,143}
\definecolor{MySpecHeaderColor}{RGB}{221,130,0}

%create new commands
\newcommand{\parallelcolor}{ %
    \color{black}\small\onehalfspacing
        }
\newcommand{\changecolor}{%
    \color{MySpecTitleColor} 
}
\newcommand{\redefinecolor}{%
    \color{black} 
}
\newcommand{\redefineweight}{%
    \bf
}
\newcommand{\setownstyle}{
%   \rmfamily
    \LARGE\color{black}
}
\newcommand{\setownspecstyle}{
%\rmfamily
\LARGE\color{MySpecHeaderColor}
}

%define renewcommands
\renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}

\AddToShipoutPictureBG{%
 \AtTextLowerLeft{\color{MySpecColor}%
 \rule{\textwidth}{\textheight}}}

\AddToShipoutPictureBG{%
 \AtTextLowerLeft{\color{MySpecColor}%
 \rule{\textwidth}{\textheight}}} 

%define mainpart of document
\begin{document}

\setownstyle Text\\
\setownstyle Text\\
\setownspecstyle Text
\begin{spacing}{1.3}
\begin{multicols}{2}{
\parallelcolor Text
\vfill
\columnbreak
\parallelcolor Text
}
\end{multicols}
\begin{spacing}{0.7}
\begin{multicols}{2}{
\parallelcolor Text
\vfill
\columnbreak
\parallelcolor Text
}
\end{multicols}
\end{spacing}
\end{spacing}
\lipsum[1-5]

\end{document}

enter image description here

share|improve this answer
    
Yes, I tried to remove \textblock environment. But I found next troubles with margins. I need to have top, left, right, botton text margins. Now My generated text has not got them in relation to \AddToShipoutPictureBG{% \AtTextLowerLeft{\color{MySpecColor}% Add left and right margins I solved with \begin{addmargin}[0.7cm]{0.7cm} of \usepackage{scrextend}. But How to work around with top and button margins? –  Lopes Dec 15 '12 at 12:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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