1

Hello I am writing a fictional story in latex and i'm having trouble with dialogue boxes. When a character says something their name and dialogue are put together in a borderless box. However i am having trouble keeping the names and their corresponding dialogue together. The issue that is arising is presented in image below at the transition between page one an page two:

enter image description here

I want the name at the bottom of the page one to stick with the dialogue on the top of the page two. The code i used to generate this is given below. It's the new environment called "dial" that i am having issue with.

\documentclass[envcountsame,envcountchap]{article}

%used to make margins one left and right side of text
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist 


%Used to create the dialogue boxes
\newenvironment{dial}[1]
    {
        \begin{center}
            \vspace{0.3cm}
            \normalsize{\textbf{#1\\[1ex]}}
            \begin{small}
                \begin{changemargin}{2cm}{2cm}

    }
    {

                \end{changemargin}
            \end{small}
        \end{center}
    }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
hey
\end{dial}


\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
hey
\end{dial}


\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
hey
\end{dial}


\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
hey
\end{dial}


\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
hey
\end{dial}


\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here. This is the Problem right here.
\end{dial}


\begin{dial}{Abbott}
hey
\end{dial}


\begin{dial}{Costello}
hey
\end{dial}


\end{document}



    \begin{dial}{Costello}
    hey
    \end{dial}


    \end{document}

I hope this is enough information to convey my issue. Bye and hope to here from you awesomnauts soon :D

4
  • envcountsame and envcountschap are strange options ;-)
    – user31729
    Commented Mar 28, 2016 at 21:11
  • You introduce so many break points in that code it is not surprising that you get a break! Latex has lots of commands for headings and itemised lists, all of which take care to control page breaking after a heading. (here you have uses a list but with an empty item (\item[]) Commented Mar 28, 2016 at 21:13
  • Perhaps the dramatist package is more of use here?
    – user31729
    Commented Mar 28, 2016 at 21:17
  • \normalsize is not a command with argument; make \begin{small} into \small and remove \end{small}; it should be \textbf{#1}\\[1ex].
    – egreg
    Commented Mar 28, 2016 at 21:35

1 Answer 1

0

Just add a \nopagebreak to your environment between heading and content:

\newenvironment{dial}[1]
    {
        \begin{center}
            \vspace{0.3cm}
            \normalsize{\textbf{#1\\[1ex]}}
            \nopagebreak
            \begin{small}
                \begin{changemargin}{2cm}{2cm}

    }
    {

                \end{changemargin}
            \end{small}
        \end{center}
    }

While this solution should work flawlessly, note that your way of doing this may be not the best, remarkable alternatives are mentioned in the comments to your question.

2
  • SOMEBODY GET THIS GUY A SANDWICH! your awesome thanks for the super speedy help :D Commented Mar 28, 2016 at 21:24
  • @StevenDawson You're welcome. Adding a MWE always makes it really easy to help. ;)
    – dessert
    Commented Mar 28, 2016 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .