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.

My friend is taking pre-calculus class, and I would like to create some notes for him. Is there a way I can do the following in latex?

Right now I only have the very basic down. I want to make it look nicer and more personal. (The color can stay black, but I used a red pen to show what I wanted to do. Thank you all in advance.)

enter image description here

$ax^2 \ + \ bx \ + \ c \ \ \ \ (where \ a \neq 1)$\\
$k_1 \ + \ k_2 \ = \ b \ \ \ \ and \ \ \ \ (k_1)(k_2) \ = \ ac$ \\ \\ 
$ax^2 \ + \ bx \ + \ c \ \ \ \ (where \ a \ = \  1)$\\
$k_1 \ + \ k_2 \ = \ a \ \ \ \ and \ \ \ \ (k_1)(k_2) \ = \ b$
share|improve this question
    
So you want to underline and right-brace the equation set. What about the horizontal alignment? –  Werner Jun 6 at 2:01
    
@Werner In the middle would be great, I am having most difficult with the right-brace and add the word to remind him they are different. –  George Jun 6 at 2:07

6 Answers 6

up vote 28 down vote accepted

Example with coloring:

\documentclass{article}
\usepackage{amsmath}
\usepackage{color}
\newcommand*{\colorunderline}[2]{%
  \underline{#2\color{#1}}%
}

\begin{document}
\[
  \renewcommand*{\arraystretch}{1.2}
  \left.\kern-\nulldelimiterspace
  \begin{array}{l@{\qquad}l}
    ax^2 + bx + c & (\colorunderline{red}{\text{where}\quad a \ne 1})\\
    k_1 + k_2 = b & \text{and}\qquad (k_1)(k_2) = ac\\[2ex]
    ax^2 + bx + c & (\colorunderline{red}{\text{where}\quad a = 1})\\
    k_1 + k_2 = a & \text{and}\qquad (k_1)(k_2) =b
  \end{array}
  \color{red}
  \right\}
  \textcolor{red}{%
    \begin{tabular}{@{}l@{}}
      very\\
      different!
    \end{tabular}%
  }
\]
\end{document}

Result

The same distance of the red underline can be achieved, if the second case includes \vphantom{\ne}:

(\colorunderline{red}{\text{where}\quad a = 1\vphantom{\ne}})

Result

Colored \underline

The "simple" definition

\newcommand*{\colorunderlinex}[2]{%
  \underline{#2\color{#1}}%
}

works with a trick. First TeX processes the argument to make a math formula. \color automatically uses \aftergroup to reset the color. Then the math formula is put in a vertical box. The latest whatsit in the formula is the switch to the underline color. Then TeX puts the line below the formula. Finally the color whatsit that was set by \aftergroup resets the color after the underlined box construct.

However this is not compatible to coloring package luacolor via LuaTeX attributes. The following definition works for package luacolor. It needs package xcolor, because this package adds a concept of a current color (.).

The current color . is saved with name current. Then the color for the underline is set for the whole construct. The math formula is set with the previously saved color current:

\newcommand*{\colorunderline}{}
\def\colorunderline#1#{%
  \colorunderlineAux{#1}%
}
\def\colorunderlineAux#1#2#3{%
  \begingroup
    \colorlet{current}{.}%
    \color#1{#2}%
    \underline{%
      \begingroup
        \color{current}#3%
      \endgroup
    }%
  \endgroup
}
  • This definition also supports an optional argument with the color model the same way, \textcolor implements it.

  • The additional grouping level inside \underline is necessary, if the color is implemented via whatsits (package color). In the latter case the "simple" definition is more efficient, because it only uses two color whatsits instead of four in the definition for luacolor.

share|improve this answer
    
out of interest, how do you set that nice background colour? –  Thruston Jun 7 at 9:34
    
@Thruston: Transparent background of the image in a quotation block (>). –  Heiko Oberdiek Jun 7 at 10:00
    
Neat. But going back to the answer, do you think it would look better if you included the parentheses in the underlining? Then both rules would be the same distance from the baseline. –  Thruston Jun 7 at 10:02
    
@Thruston: I was closely following the image in the question. You can also get the same distance, if \vphantom{\ne} is added to the second case, see the updated answer. –  Heiko Oberdiek Jun 7 at 10:04

I wouldn't use underlining to emphasize material -- better to just typeset the material in red.

enter image description here

\documentclass{article}
\usepackage{mathtools,xcolor}
\newcommand{\redemph}[1]{\text{\color{red}#1}} % handy shortcut macro
\begin{document}
\[
\begin{drcases*}
ax^2+ bx+c    &\redemph{where $ a \neq 1$}\\
k_1 + k_2 = b &\text{and $k_1k_2 = ac$} \\[2ex]
ax^2 + bx + c &\redemph{where $a =  1$}\\
k_1 + k_2 = a &\text{and $k_1k_2 = b$}\\
\end{drcases*} \redemph{\bfseries Very Different!}
\]
\end{document}
share|improve this answer
2  
I agree, but I would additionally define a \newcommand{\mathemph}[1]{\color{red}#1} inside that environment to keep markup semantic –  WChargin Jun 6 at 4:36
    
@WChargin - Thanks for this suggestion, which I've incorporated in the MWE as a macro named \redemph. –  Mico Jun 6 at 14:01

mathtools provides rcases:

enter image description here

\documentclass{article}
\usepackage{mathtools,lipsum}
\begin{document}
\lipsum[2]
\[
  \begin{rcases}
    ax^2 + bx + c \quad \text{\underline{(where $a \neq 1$)}} \\
    k_1 + k_2 = b \quad \text{and} \quad k_1 k_2 = ac \\ \\
    ax^2 + bx + c \quad \text{\underline{(where $a = 1$)}} \\
    k_1 + k_2 = a \quad \text{and} \quad k_1 k_2 = b
  \end{rcases}
  \begin{tabular}{l} VERY \\ DIFFERENT \end{tabular}
\]
\lipsum[2]
\end{document}
share|improve this answer

You can use an array:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \[ 
    \left. 
   \begin{array}{l@{\qquad}l}
    ax^{2} + bx + c  &  \text{\underline{(where $a\neq 1$)}} \\
    k_{1} + k_{2} =b &  \text{and $(k_{1})(k_{2}) = c$}\\[2\jot]
    ax^{2} + bx + c  &  \text{(where $a\neq 1$)} \\
    k_{1} + k_{2} =b &  \text{and $(k_{1})(k_{2}) = c$}
  \end{array}
  \right\} \text{Very different}
  \]
\end{document}

enter image description here

share|improve this answer

With stacks.

\documentclass{article}
\usepackage{tabstackengine}
\usepackage{xcolor}
\newcommand\culine[2]{\textcolor{#1}{\protect\underline{\textcolor{black}{#2}}}}
\begin{document}
\[
  \setstacktabulargap{2em}\setstackgap{L}{1.2\baselineskip}
  \left.\tabularCenterstack{ll}{
    $ax^2 + bx + c$ & (\culine{red}{where$\quad a \ne 1$})\\
    $k_1 + k_2 = b$ & and $\quad(k_1)(k_2) = ac$\\\\
    $ax^2 + bx + c$ & (\culine{red}{where$\quad a = 1$})\\
    $k_1 + k_2 = a$ & and$\qquad (k_1)(k_2) =b$
  }
  \color{red}\right\}\textsf{\small\textcolor{red}{\Centerstack[l]{VERY\\DIFFERENT!}}}
\]
\end{document}

enter image description here

share|improve this answer

With Plain TeX vcenter and halign and a custom "underline-in-red" macro:

\documentclass{article}
\usepackage{color}
\begin{document}
\def\ur#1{\setbox0\hbox{#1}\hbox to 0pt{\color{red}\vrule depth 3.2pt height -2.6pt width \wd0\hss}\box0}
$$
\left.
\vcenter{\openup3pt\halign{$#$\hfil\quad\cr
  ax^2+bx+c \quad (\ur{where $a\not=1$})\cr
  k_1+k_2=b \quad\hbox{and}\quad (k_1)(k_2) = ac\cr
  \noalign{\bigskip}
  ax^2+bx+c \quad (\ur{where $a=1$})\cr
  k_1+k_2=a \quad\hbox{and}\quad (k_1)(k_2) = b\cr
  }}
\color{red}\right\} 
\hbox{\color{red}Very different!}
$$
\end{document}

enter image description here

share|improve this answer

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.