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 a document consisting of alternating paragraphs from different voices. Because the paragraph blocks look too much alike, I need some way to give the different parts a different look.

I have already tried options such as changing to italics or bold face, but I do not want to hinder readability. I wonder if there other environments in which I can place the around some paragraphs or other visual elements which I can use to let readers easily know which part is which?

share|improve this question
    
Related Question: To clearly separate block inside a chapter. –  Peter Grill Feb 20 at 18:47

1 Answer 1

up vote 30 down vote accepted

There are numerous ways to do this:

  1. You could simply use different colored text, or perhaps a combination of the following will yield the desired something to your liking.

  2. Here is an example of using the mdframed package to highlight the different sections:

    enter image description here

  3. You could use adjustwidth environment from the changepage package to visually separate the two paragraphs:

    enter image description here

  4. You could use the changebar package:

    enter image description here

  5. If your paragraphs are not too large you could use the solution from Mark portions of text without affecting spacing to make the begin and end of the paragraphs:

    enter image description here

  6. In case you want to have solutions which do not require using separate paragraphs, here is a version comparable to the mdframed, which uses the solution from Cool Text Highlighting in LaTeX to provide highlighting which appears manually generated: enter image description here


Code: mdframed:

\documentclass[border=5pt]{standalone}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{lipsum}

\newmdenv[
    backgroundcolor=yellow!10,
    rightline=false,
    leftline=false,
    topline=false,
    bottomline=false,
    innertopmargin=1pt,
    innerbottommargin=1pt,
    innerleftmargin=0,
    innerrightmargin=0,
]{VoiceA}

\newmdenv[
    backgroundcolor=gray!10,
    rightline=false,
    leftline=false,
    topline=false,
    bottomline=false,
    innertopmargin=1pt,
    innerbottommargin=1pt,
    innerleftmargin=0,
    innerrightmargin=0,
]{VoiceB}

\begin{document}
\begin{VoiceA}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Phasellus ut elit ipsum. 
    In massa metus, suscipit vel semper in, sodales sed risus. 
    Aliquam gravida ultricies sollicitudin. 
\end{VoiceA}
\begin{VoiceB}
    Vivamus et sem velit. 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam erat volutpat. 
    Sed rhoncus neque a orci vulputate ut elementum dui ornare.  
\end{VoiceB}
\begin{VoiceA}
    Nulla id magna metus. Integer lacus dolor, tempus ac sodales 
    eu, blandit nec ligula. 
    Etiam quis arcu ac nisi lobortis ultricies quis in dolor. 
    Quisque lobortis magna arcu.
\end{VoiceA}
\end{document}

Code: adjustwidth:

\documentclass[border=5pt]{standalone}
\usepackage{lipsum}
\usepackage{changepage}

\newenvironment{VoiceA}{%
    \begin{adjustwidth}{0pt}{1.0cm}%
}{%
    \end{adjustwidth}%
}

\newenvironment{VoiceB}{%
    \begin{adjustwidth}{1.0cm}{0pt}%
}{%
    \end{adjustwidth}%
}
\begin{document}
\begin{VoiceA}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Phasellus ut elit ipsum. 
    In massa metus, suscipit vel semper in, sodales sed risus. 
    Aliquam gravida ultricies sollicitudin. 
\end{VoiceA}
\begin{VoiceB}
    Vivamus et sem velit. 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam erat volutpat. 
    Sed rhoncus neque a orci vulputate ut elementum dui ornare.  
\end{VoiceB}
\begin{VoiceA}
    Nulla id magna metus. Integer lacus dolor, tempus ac sodales 
    eu, blandit nec ligula. 
    Etiam quis arcu ac nisi lobortis ultricies quis in dolor. 
    Quisque lobortis magna arcu.
\end{VoiceA}
\end{document}

Code: changebar:

\documentclass{article}
\usepackage{lipsum}
\usepackage[xcolor,outerbars]{changebar}

\setlength\changebarsep{5pt}
\newenvironment{VoiceA}{%
    \cbcolor{red}%
    \par%
    \cbstart%
}{%
%
    \cbend%
}

\newenvironment{VoiceB}{%
    \cbcolor{white}% gets cluttered if both have changebars
    \par%
    \cbstart%
}{%
    \cbend%
}
\begin{document}
\begin{VoiceA}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Phasellus ut elit ipsum. 
    In massa metus, suscipit vel semper in, sodales sed risus. 
    Aliquam gravida ultricies sollicitudin. 
\end{VoiceA}
\begin{VoiceB}
    Vivamus et sem velit. 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam erat volutpat. 
    Sed rhoncus neque a orci vulputate ut elementum dui ornare.  
\end{VoiceB}
\begin{VoiceA}
    Nulla id magna metus. Integer lacus dolor, tempus ac sodales 
    eu, blandit nec ligula. 
    Etiam quis arcu ac nisi lobortis ultricies quis in dolor. 
    Quisque lobortis magna arcu.
\end{VoiceA}
\end{document}

Code: Paragraph Markers:

\documentclass[border=5pt]{standalone}
\usepackage{environ}
\usepackage{tikz}
\usepackage{mathabx}

% http://tex.stackexchange.com/questions/24174/mark-portions-of-text-without-affecting-spacing

\DeclareRobustCommand{\MarkStart}[1]{{%
  \setbox0=\llap{\raisebox{5pt}{\color{#1}$\Rsh$\kern-6pt}}%
  \ht0=0pt \dp0=0pt \leavevmode\box0
}}
\DeclareRobustCommand{\MarkEnd}[1]{{%
  \setbox0=\rlap{\raisebox{5pt}{\color{#1}\kern-6pt$\Lsh$}}%
  \ht0=0pt \dp0=0pt \leavevmode\box0
}}
\newcommand*{\Mark}[1]{\MarkStart#1\MarkEnd}

\NewEnviron{VoiceA}{\par\MarkStart{red}\BODY\MarkEnd{red}}
\NewEnviron{VoiceB}{\par\MarkStart{blue}\BODY\MarkEnd{blue}}

\begin{document}
\begin{VoiceA}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Phasellus ut elit ipsum. 
    In massa metus, suscipit vel semper in, sodales sed risus. 
    Aliquam gravida ultricies sollicitudin. 
\end{VoiceA}
\begin{VoiceB}
    Vivamus et sem velit. 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam erat volutpat. 
    Sed rhoncus neque a orci vulputate ut elementum dui ornare.  
\end{VoiceB}
\begin{VoiceA}
    Nulla id magna metus. Integer lacus dolor, tempus ac sodales 
    eu, blandit nec ligula. 
    Etiam quis arcu ac nisi lobortis ultricies quis in dolor. 
    Quisque lobortis magna arcu.
\end{VoiceA}
\end{document}

Code: Cool Highlighting:

\documentclass[border=5pt]{standalone}
\usepackage{soul}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}

% http://tex.stackexchange.com/questions/5959/cool-text-highlighting-in-latex

\makeatletter
\newcommand{\defhighlighter}[3][]{%
  \tikzset{every highlighter/.style={color=#2, fill opacity=#3, #1}}%
}

\defhighlighter{yellow}{.3}

\newcommand{\highlight@DoHighlight}{
  \fill [ decoration = {random steps, amplitude=1pt, segment length=55pt}
        , outer sep = -15pt, inner sep = 0pt, decorate
        , every highlighter, this highlighter ]
        ($(begin highlight)+(0,8pt)$) rectangle ($(end highlight)+(0,-3pt)$) ;
}

\newcommand{\highlight@BeginHighlight}{
  \coordinate (begin highlight) at (0,0) ;
}

\newcommand{\highlight@EndHighlight}{
  \coordinate (end highlight) at (0,0) ;
}

\newdimen\highlight@previous
\newdimen\highlight@current

\DeclareRobustCommand*\highlight[1][]{%
  \tikzset{this highlighter/.style={#1}}%
  \SOUL@setup
  %
  \def\SOUL@preamble{%
    \begin{tikzpicture}[overlay, remember picture]
      \highlight@BeginHighlight
      \highlight@EndHighlight
    \end{tikzpicture}%
  }%
  %
  \def\SOUL@postamble{%
    \begin{tikzpicture}[overlay, remember picture]
      \highlight@EndHighlight
      \highlight@DoHighlight
    \end{tikzpicture}%
  }%
  %
  \def\SOUL@everyhyphen{%
    \discretionary{%
      \SOUL@setkern\SOUL@hyphkern
      \SOUL@sethyphenchar
      \tikz[overlay, remember picture] \highlight@EndHighlight ;%
    }{%
    }{%
      \SOUL@setkern\SOUL@charkern
    }%
  }%
  %
  \def\SOUL@everyexhyphen##1{%
    \SOUL@setkern\SOUL@hyphkern
    \hbox{##1}%
    \discretionary{%
      \tikz[overlay, remember picture] \highlight@EndHighlight ;%
    }{%
    }{%
      \SOUL@setkern\SOUL@charkern
    }%
  }%
  %
  \def\SOUL@everysyllable{%
    \begin{tikzpicture}[overlay, remember picture]
      \path let \p0 = (begin highlight), \p1 = (0,0) in \pgfextra
        \global\highlight@previous=\y0
        \global\highlight@current =\y1
      \endpgfextra (0,0) ;
      \ifdim\highlight@current < \highlight@previous
        \highlight@DoHighlight
        \highlight@BeginHighlight
      \fi
    \end{tikzpicture}%
    \the\SOUL@syllable
    \tikz[overlay, remember picture] \highlight@EndHighlight ;%
  }%
  \SOUL@
}
\makeatother

\begin{document}
\highlight[yellow]{
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Phasellus ut elit ipsum. 
    In massa metus, suscipit vel semper in, sodales sed risus. 
    Aliquam gravida ultricies sollicitudin. 
}
\highlight[gray]{
    Vivamus et sem velit. 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam erat volutpat. 
    Sed rhoncus neque a orci vulputate ut elementum dui ornare.  
}
\highlight[yellow]{
    Nulla id magna metus. Integer lacus dolor, tempus ac sodales 
    eu, blandit nec ligula. 
    Etiam quis arcu ac nisi lobortis ultricies quis in dolor. 
    Quisque lobortis magna arcu.
}
\end{document}
share|improve this answer
2  
Excellent compilation of approaches! –  Jake Dec 6 '11 at 4:00
    
Yes, very complete answer. –  Gonzalo Medina Dec 6 '11 at 13:53
    
(+1) Very nice response! –  chl Dec 6 '11 at 14:25

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.