I'm trying to create an environment where each paragraph
- gets some stylized text prepended to it (e.g. "Tips: ")
- is not allowed to be broken up across pages
Based on this answer, I've managed to achieve this using everypar and windowpenalties, but I'm wondering if there's a better way. I've read many times that everypar should be avoided if possible since many packages override it.
While my use of everypar is my main concern, I would also appreciate suggestions around windowpenalties. Is there a better approach?
MWE:
\documentclass[oneside]{book}
\usepackage{lipsum}
\usepackage{parskip}
\raggedbottom
\newenvironment{tips}
{%
\widowpenalties 1 10000%
\everypar{{\fontshape{\itdefault}\fontseries{\bfdefault}\selectfont Tip:\enspace}}%
}
{}
\begin{document}
\lipsum[1-10]
\begin{tips}
\lipsum[1-10]
\end{tips}
\lipsum[1-10]
\end{document}

\itshape\bfseries? There is almost never a need to use\selectfontin LaTeX except in defining font commands, but here you just want standard out-of-the-box stuff: italic bold. Why the fuss? – cfr Aug 29 '16 at 02:44\selectfont. (I can't remember if I show them this at all, but I certainly don't suggest they use it.) – cfr Aug 29 '16 at 03:52\everyparthat I recall. I don't remember ever using\widowpenaltieseither ....) – cfr Aug 29 '16 at 03:57\parwithin the environment work? – splicer Aug 29 '16 at 04:55\interlinepenalty = 10000, not\widoowpenalties 1 = 10000. – GuM Aug 29 '16 at 08:03