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 have written following command:

\newcommand{\ger}[2]{{\noindent\raisebox{-0.2mm} 
{\includegraphics[width=5.47mm,height=3.28mm]{Flag_1.pdf}} 
\color{red} #1\nopagebreak\\\raisebox{-0.2mm}{\includegraphics{pol.pdf}}  
\color{blue} \emph{#2}}\vspace{5pt}}

This is going to be used as follows:

\ger{First sentence}{Second sentence}

Question is, how to assert that these two sentences will be always on the same page with full content (there won't be any page breaks)? I tried to use \nopagebreak, but it still breaks sometimes part of the second sentence.

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

Instead of \\ you can use \par\nobreak to prevent page breaks:

\newcommand{\ger}[2]{{\noindent\raisebox{-0.2mm} 
{\includegraphics[width=5.47mm,height=3.28mm]{Flag_1.pdf}} 
\color{red} #1\par\nobreak\noindent\raisebox{-0.2mm}{\includegraphics{pol.pdf}}  
\color{blue}\emph{#2}}\vspace{5pt}}
share|improve this answer
add comment

One solution is to put the whole thing in a \minipage, and make that mini page a float.

Edit

Per request, an example:

\newcommand{\ger}[2]{%
  \begin{figure}
    \begin{minipage}{\textwidth}
      \noindent
      \raisebox{-0.2mm}{\includegraphics[width=5.47mm,height=3.28mm]{Flag_1.pdf}} 
      \color{red}{#1}\\
      \raisebox{-0.2mm}{\includegraphics{pol.pdf}}  
      \color{blue}{\emph{#2}}
    \end{minipage}
  \end{figure}}

You may want to add a \caption and a \label as well.

share|improve this answer
    
I think this is the simpler, cleaner solution as a concept, but I'm not going to vote it up, unless you'd like to provide sufficiently simple example code... –  Brent.Longborough Jun 17 '11 at 10:24
    
@Brent: Example code added. –  David Hammen Jun 19 '11 at 11:02
    
why a float? –  egreg Jun 19 '11 at 11:09
    
@egreg: A float isn't essential here. However, my experience is that tall boxes/minipages often create overfull/underfull vbox problems. At least in my usage, those tall boxes/minipages almost always result from describing something graphically or tabularly: A figure or a table. –  David Hammen Jun 19 '11 at 11:21
    
+1 as promised... –  Brent.Longborough Jun 19 '11 at 17:21
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.