LaTeX forum ⇒ Text FormattingNo Pagebreak for a certain group of paragraphs Topic is solved

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

No Pagebreak for a certain group of paragraphs

Postby marek_step » Thu Jan 01, 2015 1:26 pm

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

  1. \documentclass[twoside,a4paper,headsepline=yes,draft=true]{scrreprt}
  2. \usepackage[ngerman]{babel}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage{color}
  5. \usepackage{eurosym}
  6. \definecolor{LGrey}{rgb}{.6,.6,.6}
  7. \definecolor{LBlue}{rgb}{.1,.4,1}
  8. \definecolor{LRed}{rgb}{.6,0,0}
  9. \newcommand{\puh}{\textcolor{LBlue}{\textsc{Anette: }}}
  10. \newcommand{\maaki}{\textcolor{LBlue}{\textsc{Marek: }}}
  11. \newcommand{\datum}[1]{\textcolor{LGrey}{\begin{center}{\ttfamily #1}\end{center}}}
  12.  
  13. \usepackage[T1]{fontenc}
  14. \input Acorn.fd
  15. \newcommand*\initfamily{\usefont{U}{Acorn}{xl}{n}} % this is for the decorative Title
  16.  
  17. \usepackage{graphicx}
  18. \usepackage{caption}
  19. \usepackage{float}
  20. \usepackage{wrapfig}
  21. \usepackage{wasysym} % to insert smileys
  22. \usepackage{blindtext}
  23.  
  24. \usepackage[colorlinks=false,breaklinks=true]{hyperref}
  25. \def\UrlBreaks{\do\/\do-\do_}
  26.  
  27. \clubpenalty = 10000 % schliesst Schusterjungen aus
  28. \widowpenalty = 10000 % schliesst Hurenkinder aus
  29.  
  30. \begin{document}
  31.  
  32. \fontsize{10pt}{10pt}\selectfont\normalfont
  33.  
  34. \setlength{\parindent}{0pt}
  35. \setlength{\parskip}{0.2em}
  36.  
  37. \section*{SMS Data from - }
  38.  
  39. \begin{samepage}
  40. \datum{Sonntag, 26.05.2013 - 14:13:27}
  41.  
  42. \puh \blindtext
  43. \end{samepage}
  44.  
  45. \begin{samepage}
  46. \datum{- 14:35:47}
  47.  
  48. \maaki \blindtext
  49. \end{samepage}
  50.  
  51. \begin{samepage}
  52. \datum{- 14:49:15}
  53.  
  54. \puh :-))
  55. \end{samepage}
  56.  
  57. \begin{samepage}
  58. \datum{Mittwoch, 05.06.2013 - 19:12:09}
  59.  
  60. \puh \Blindtext
  61. \end{samepage}
  62.  
  63. \begin{samepage}
  64. \datum{- 20:16:47}
  65.  
  66. \maaki \blindtext
  67. \end{samepage}
  68.  
  69. \begin{samepage}
  70. \datum{- 20:17:30}
  71.  
  72. \puh Prima! Danke!!
  73. \end{samepage}
  74.  
  75. \begin{samepage}
  76. \datum{Samstag, 08.06.2013 - 10:21:09}
  77.  
  78. \maaki \blindtext
  79. \end{samepage}
  80.  
  81. \begin{samepage}
  82. \datum{- 11:08:45}
  83.  
  84. \puh \blindtext
  85. \end{samepage}
  86.  
  87. \begin{samepage}
  88. \datum{Freitag, 12.07.2013 - 08:09:45}
  89.  
  90. \puh \blindtext
  91. \end{samepage}
  92.  
  93. \begin{samepage}
  94. \datum{Mittwoch, 17.07.2013 - 10:05:32}
  95.  
  96. \maaki \blindtext\\\\Grüße marek
  97. \end{samepage}
  98.  
  99. \begin{samepage}
  100. \datum{- 21:45:34}
  101.  
  102. \puh \blindtext
  103. \end{samepage}
  104.  
  105. \begin{samepage}
  106. \datum{- 21:46:46}
  107.  
  108. \maaki \blindtext
  109. \end{samepage}
  110.  
  111. \begin{samepage}
  112. \datum{Samstag, 20.07.2013 - 16:06:09}
  113.  
  114. \puh \blindtext
  115. \end{samepage}
  116.  
  117. \begin{samepage}
  118. \datum{- 16:24:01}
  119.  
  120. \maaki \blindtext
  121. \end{samepage}
  122.  
  123. \begin{samepage}
  124. \datum{- 16:35:31}
  125.  
  126. \puh \blindtext
  127. \end{samepage}
  128.  
  129. \begin{samepage}
  130. \datum{- 16:36:31}
  131.  
  132. \maaki \blindtext
  133. \end{samepage}
  134.  
  135. \end{document}

Tags:

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

Postby Johannes_B » Mon Jan 05, 2015 11:37 am

I think you are looking for minipages.
  1. %s/begin{samepage}/begin{minipage}{\\textwidth}/g
  2. %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

Postby marek_step » Mon Jan 05, 2015 2:06 pm

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: 9434
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Jan 05, 2015 2:13 pm

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
Site admin

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

Postby Stefan Kottwitz » Mon Jan 05, 2015 2:27 pm

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
    1. \newcommand*{\person}[1]{\textcolor{LBlue}{\textsc{#1: }}}
    2. \newcommand*{\puh}{\person{Anette}}
    3. \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.
Site admin

marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

Postby marek_step » Tue Jan 06, 2015 4:07 pm

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: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Jan 06, 2015 4:20 pm

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:
  1. %contents of a normal chapter
  2. \begingroup
  3. %switch to fancy font
  4. \chapter{Fancy Chapter}
  5. with fancy text
  6. \clearpage
  7. \endgroup
  8.  
  9. \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: 9434
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Jan 06, 2015 4:26 pm

Hi Marek,

you could simply use the command \normalsize.

Stefan
Site admin

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

Postby Johannes_B » Tue Jan 06, 2015 4:43 pm

In the following example, the font switches are trapped inside the minipages
  1. \documentclass[parskip=half,twoside,a4paper,headsepline=yes,draft=true]{scrreprt}
  2. \usepackage[ngerman]{babel}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage{xcolor}
  5. \usepackage{microtype}
  6. \definecolor{LGrey}{rgb}{.6,.6,.6}
  7. \definecolor{LBlue}{rgb}{.1,.4,1}
  8. \definecolor{LRed}{rgb}{.6,0,0}
  9. \newcommand{\datum}[1]{\textcolor{LGrey}{\begin{center}{\ttfamily #1}\end{center}}}
  10. \newcommand*{\person}[1]{\textcolor{LBlue}{\textsc{#1: }}}
  11. \newcommand*{\puh}{\person{Anette}}
  12. \newcommand*{\maaki}{\person{Marek}}
  13.  
  14. \usepackage[T1]{fontenc}
  15. \input{Acorn.fd}
  16. \newcommand*\initfamily{\usefont{U}{Acorn}{xl}{n}} % this is for the decorative Title
  17.  
  18. \usepackage{blindtext}
  19.  
  20. \usepackage[colorlinks=false,breaklinks=true]{hyperref}
  21. \def\UrlBreaks{\do\/\do-\do_}
  22.  
  23. \usepackage{showframe}
  24.  
  25. \newenvironment{sms}[2]{%
  26. \noindent\begin{minipage}{.97\linewidth}\datum{#1}\person{#2}%
  27. \KOMAoption{parskip}{half}%
  28. }{%
  29. \par\end{minipage}}
  30.  
  31. \newcommand{\loveletter}{%
  32. \usefont{T1}{qcs}{m}{n}\fontsize{14pt}{14pt}\selectfont}
  33.  
  34. \begin{document}
  35. \addsec{SMS Data from - }%if you want it to appear in the TOC
  36.  
  37. \begin{sms}{Sonntag, 26.05.2013 - 14:13:27}{\puh}
  38. \blindtext
  39.  
  40. \blindtext
  41. \end{sms}
  42.  
  43. \begin{sms}{- 14:35:47}{\maaki}
  44. \loveletter
  45. \blindtext
  46. \end{sms}
  47.  
  48. \begin{sms}{- 14:49:15}{\puh}
  49. :-))
  50. \end{sms}
  51. \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

Postby marek_step » Tue Jan 06, 2015 4:50 pm

:-))

This time so fast! Thank you!

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

Greeting


marek


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests