Text FormattingNo Pagebreak for a certain group of paragraphs

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

No Pagebreak for a certain group of paragraphs

Post by marek_step »

Hello all! Happy New Year 2015! Hope that all your wishes and dreams become true - finally this year!

I have a long list of SMS Data with groups, which I have put into the environment "samepage" , to hinder a page break:

\begin{samepage}
Date - Time (centered)
Person: Text Message
\end{samepage}

But this is not working ! I tried already with \nopagebreak[4] - etc to no avail. I put up a long example to demonstrate the problem: between page 2 and 3 it is not working :-(

As a little add: if you as professionals have suggestions for a nicer formatting, I would be grateful for every suggestion - for example make the Person name float to the left perhaps?

Best greetings to all from Munich

yours marek

Code: Select all


\documentclass[twoside,a4paper,headsepline=yes,draft=true]{scrreprt}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{eurosym}
\definecolor{LGrey}{rgb}{.6,.6,.6}
\definecolor{LBlue}{rgb}{.1,.4,1}
\definecolor{LRed}{rgb}{.6,0,0}
\newcommand{\puh}{\textcolor{LBlue}{\textsc{Anette: }}}
\newcommand{\maaki}{\textcolor{LBlue}{\textsc{Marek: }}}
\newcommand{\datum}[1]{\textcolor{LGrey}{\begin{center}{\ttfamily #1}\end{center}}}

\usepackage[T1]{fontenc}
\input Acorn.fd
\newcommand*\initfamily{\usefont{U}{Acorn}{xl}{n}} % this is for the decorative Title

\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{wasysym} % to insert smileys
\usepackage{blindtext}

\usepackage[colorlinks=false,breaklinks=true]{hyperref}
\def\UrlBreaks{\do\/\do-\do_}

\clubpenalty = 10000 % schliesst Schusterjungen aus
\widowpenalty = 10000 % schliesst Hurenkinder aus

\begin{document}

\fontsize{10pt}{10pt}\selectfont\normalfont

\setlength{\parindent}{0pt}
\setlength{\parskip}{0.2em}

\section*{SMS Data from - }

\begin{samepage}
\datum{Sonntag, 26.05.2013 - 14:13:27}

\puh  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 14:35:47}

\maaki  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 14:49:15}

\puh  :-))
\end{samepage}

\begin{samepage}
\datum{Mittwoch, 05.06.2013 - 19:12:09}

\puh  \Blindtext
\end{samepage}

\begin{samepage}
\datum{- 20:16:47}

\maaki  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 20:17:30}

\puh  Prima! Danke!!
\end{samepage}

\begin{samepage}
\datum{Samstag, 08.06.2013 - 10:21:09}

\maaki  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 11:08:45}

\puh  \blindtext
\end{samepage}

\begin{samepage}
\datum{Freitag, 12.07.2013 - 08:09:45}

\puh  \blindtext
\end{samepage}

\begin{samepage}
\datum{Mittwoch, 17.07.2013 - 10:05:32}

\maaki  \blindtext\\\\Grüße marek
\end{samepage}

\begin{samepage}
\datum{- 21:45:34}

\puh  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 21:46:46}

\maaki  \blindtext
\end{samepage}

\begin{samepage}
\datum{Samstag, 20.07.2013 - 16:06:09}

\puh  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 16:24:01}

\maaki  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 16:35:31}

\puh  \blindtext
\end{samepage}

\begin{samepage}
\datum{- 16:36:31}

\maaki  \blindtext
\end{samepage}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

No Pagebreak for a certain group of paragraphs

Post by Johannes_B »

I think you are looking for minipages.

Code: Select all

%s/begin{samepage}/begin{minipage}{\\textwidth}/g
%s/samepage/minipage/
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

Re: No Pagebreak for a certain group of paragraphs

Post by marek_step »

Thank you Johannes_B! Should have had the idea for myself! :oops:

Do you have some hints for a nicer layout?

In any case thank you for the nice forum and best wishes to you and the forum for the new year 2015 ...


marek
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

No Pagebreak for a certain group of paragraphs

Post by Stefan Kottwitz »

Hi Marek,

happe new year! And greetings from Hamburg to Munich. :-)

By the way, if you would prefer to write in German, I gladly invite you to our German partner site TeXwelt.de. It has a special interface with voting and sorting by votes and detailed tagging, for building an optimal knowledge database built on questions and answers.

Best regards,

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

No Pagebreak for a certain group of paragraphs

Post by Stefan Kottwitz »

Now that I read further, some ideas:
  • Load microtype for better justification: \usepackage{microtype}
  • Use xcolor instead of color
  • Define a consistent style for persons once, instead of each time for each single person, such as

    Code: Select all

    \newcommand*{\person}[1]{\textcolor{LBlue}{\textsc{#1: }}}
    \newcommand*{\puh}{\person{Anette}}
    \newcommand*{\maaki}{\person{Marek}}
    This makes changes easier and consistent.
  • A \parskip of 0.2em looks a bit strange, more like an error than a design element if I see that very small extra skip between the lines. Btw. the class provides options such as halfparskip for this.
  • I would not do physical things such as \fontsize{10pt}{10pt}\selectfont in the document. Instead, I would define a macro for this in the preamble, calling only that macro in the document. This is especially meaningful if there would be some more size changes.
  • A line skip with the same value like the font height is not so well readable. Letters may nearly touch each other.
LaTeX.org admin
marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

No Pagebreak for a certain group of paragraphs

Post by marek_step »

Thank you Stefan_K :-)

I am very happy, that you took so much time, to answer my supplemental questions about formatting the SMS-messages.

I read carefully all docs connected to your suggested packages. Concerning the \selectfont and the \fontsize, I only wanted to go back to the default settings of my doctype: \documentclass[...]{scrreprt}, because in the chapter before I am using an other fancy font of the package aurical - \Fontlukas\fontsize{6mm}{6mm}\selectfont I only need to come back to the default font and shape. \selectfont\normalfont seems not to work (the font is very big).

If you could give me a hint, I would be very grateful.


Greetings again from Munich - we have a holiday here in Bavaria (Drei Heilige Könige).


marek
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

No Pagebreak for a certain group of paragraphs

Post by Johannes_B »

If you want to keep stuff localized, use groups. I don't know your exact setup, but it should look a bit like the following:

Code: Select all

%contents of a normal chapter
\begingroup
%switch to fancy font
\chapter{Fancy Chapter}
with fancy text
\clearpage
\endgroup

\chapter{Back to normal}
With (La)TeX you can keep things local using groups, this is a bit like a fence where the font switch rabbit cannot break out ;-)

Not sure if the clearpage at the end will be necessary, but it will do no harm.

By the way, concerning the fonts, the first value determines the size of the font, the second value gives the skip between two baselines and should therefore be a bit larger.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

No Pagebreak for a certain group of paragraphs

Post by Stefan Kottwitz »

Hi Marek,

you could simply use the command \normalsize.

Stefan
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

No Pagebreak for a certain group of paragraphs

Post by Johannes_B »

In the following example, the font switches are trapped inside the minipages

Code: Select all

\documentclass[parskip=half,twoside,a4paper,headsepline=yes,draft=true]{scrreprt}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{microtype}
\definecolor{LGrey}{rgb}{.6,.6,.6}
\definecolor{LBlue}{rgb}{.1,.4,1}
\definecolor{LRed}{rgb}{.6,0,0}
\newcommand{\datum}[1]{\textcolor{LGrey}{\begin{center}{\ttfamily #1}\end{center}}}
\newcommand*{\person}[1]{\textcolor{LBlue}{\textsc{#1: }}}
\newcommand*{\puh}{\person{Anette}}
\newcommand*{\maaki}{\person{Marek}}

\usepackage[T1]{fontenc}
\input{Acorn.fd}
\newcommand*\initfamily{\usefont{U}{Acorn}{xl}{n}} % this is for the decorative Title

\usepackage{blindtext}

\usepackage[colorlinks=false,breaklinks=true]{hyperref}
\def\UrlBreaks{\do\/\do-\do_}

\usepackage{showframe}

\newenvironment{sms}[2]{%
	\noindent\begin{minipage}{.97\linewidth}\datum{#1}\person{#2}%
		\KOMAoption{parskip}{half}%
	}{%
	\par\end{minipage}}

\newcommand{\loveletter}{%
\usefont{T1}{qcs}{m}{n}\fontsize{14pt}{14pt}\selectfont}

\begin{document}
\addsec{SMS Data from - }%if you want it to appear in the TOC

\begin{sms}{Sonntag, 26.05.2013 - 14:13:27}{\puh}
	\blindtext

	\blindtext
\end{sms}

\begin{sms}{- 14:35:47}{\maaki}
	\loveletter
	\blindtext
\end{sms}

\begin{sms}{- 14:49:15}{\puh}
	:-))
\end{sms}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

Re: No Pagebreak for a certain group of paragraphs

Post by marek_step »

:-))

This time so fast! Thank you!

And the best in your answer was "loveletter" :-))

Greeting


marek
Post Reply