2

The following is a piece of LaTeX code displaying a function. But in the PDF file generated, the right curly bracket "}" does not show up at the end. If I replace \right\} with just \}, then the right bracket show up, but I want the larger one. One complication maybe that my equation is really long, so I had to break it up over multiple lines. Another problem I am having is that I want to line up my equation section, so I am using:

\subitem\space\space\space\space\space\space\space\space\space\space
\space\space\space\space\space\space\space\space \(` equation line `\) \\

There has to be a better way to do this.

Could anyone please point out to me how I can insert a large right curly bracket and have all the equation pieces line up based off of the left parenthesis "("?

Here's what I currently have:

enter image description here

And the code:

\documentclass[titlepage]{scrartcl}
\usepackage[utf8]{inputenc}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage{geometry}
\geometry{left=1in,right=1in,top=1in,bottom=1in}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{class}
\rhead{name}
\cfoot{\thepage} %center of the footer!
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\begin{description}
\item[\space\space\space\space\space\space\space ii.]Calculate the covariance matrix of each class (\(\Sigma_{1}, \Sigma_{2}\)) manually.
\\ \\
answer:
    \subitem \(\displaystyle \Sigma_{1} = \frac{1}{2-1}\left\{
    \left(\left[\begin{array}{c} 0.80 \\ 1.2\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)
    \left(\left[\begin{array}{c} 0.80 \\ 1.2\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)^{T} + \) 
    \subitem \space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space \(
    \left(\left[\begin{array}{c} 0.90 \\ 1.4\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)
    \left(\left[\begin{array}{c} 0.90 \\ 1.4\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)^{T} + 
    \right\}\)
    \subitem \space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space \(
    \left(\left[\begin{array}{c} 0.90 \\ 1.4\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)
    \left(\left[\begin{array}{c} 0.90 \\ 1.4\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)^{T} + 
    \right\}\)
    \subitem \space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space \(
    \left(\left[\begin{array}{c} 0.90 \\ 1.4\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)
    \left(\left[\begin{array}{c} 0.90 \\ 1.4\end{array}\right]-\left[\begin{array}{c} 1.0 \\ 1.375\end{array}\right]\right)^{T} \right\}\)
\end{description}
\end{document}
  • 2
    (1) left right constructions cannot be broken across lines. (2) you are aware of the bmatrix (or is is Bmatrix) environment, which will greatly simplify your code. (3) please always remember to post something fully compilable, this is missing preamble etc – daleif Sep 20 '15 at 17:28
  • Is there a way to get the format that I would like to have? I don't know what bmatrix is.. Also, what am I missing so that it will compile? I'm very new to LaTeX :/ – Casey Sep 20 '15 at 17:31
  • bmatrix is defined by the amsmath package, I recommend having a look through its manual to see what it can offer. As for what is missing: the preamble, i.e. \documentclass and any required packages. Then adding \begin{document} and \end{document} will allow others to copy-paste the code and compile it without making any modifications. – Torbjørn T. Sep 20 '15 at 17:49
  • You can add your code pretty printed selecting all the lines and clicking the {} button. – Manuel Sep 20 '15 at 17:50
3

Suggestion to simplify your code.

\documentclass{scrartcl}
\usepackage{mathtools}

\newcommand*\bect[1]{\bectaux#1\relax} % bracketed vec
\def\bectaux#1,#2\relax{\begin{bmatrix}#1\\#2\end{bmatrix}}

\begin{document}
\[
  \Sigma_1 = \frac{1}{2-1}
    \!\begin{aligned}[t]
      \Biggl\{
        & \biggl( \bect{0.80,1.2} - \bect{1.0,1.375} \biggr) \biggl( \bect{0.80,1.2} - \bect{1.0,1.375} \biggr)^T + \\
        & \biggl( \bect{0.90,1.4} - \bect{1.0,1.375} \biggr) \biggl( \bect{0.90,1.4} - \bect{1.0,1.375} \biggr)^T + \\
        & \biggl( \bect{0.90,1.4} - \bect{1.0,1.375} \biggr) \biggl( \bect{0.90,1.4} - \bect{1.0,1.375} \biggr)^T + \\
        & \biggl( \bect{0.90,1.4} - \bect{1.0,1.375} \biggr) \biggl( \bect{0.90,1.4} - \bect{1.0,1.375} \biggr)^T
      \Biggr\}
    \end{aligned}
\]
\end{document}

enter image description here

  • 1
    The usual way here to say thanks is upvoting if you think an answer deserves it, and accepting the answer that mostly helped you. In any case, remember what daleif said in his comment, your question without a minimal compilable example is useless, because we can't reproduce your problem. – Manuel Sep 20 '15 at 17:40
  • I added to the code. Are my changes what you need to reproduce my problem? – Casey Sep 20 '15 at 17:49
  • This answer wasn't planned on solving your problems, but providing a solution from zero. That recomendation was general for every question :) In any case, at first glance you have a missing \) at the end. – Manuel Sep 20 '15 at 17:52
  • I'm not sure that replacing \\ with a comma is good. – egreg Sep 20 '15 at 19:55
  • @egreg This is just one way of attacking this code. May be more secure would be \bect{x;y} because ; is not used usually. But I definitely prefer this interface rather than \bect{x\\y} or even \begin{bmatrix}x\\y\end{bmatrix}. – Manuel Sep 20 '15 at 20:13
0

There is no document command \subitem; it is defined but only for use in the index.1

Also typing rows of \space commands is surely to be avoided. I can assure you that I may have typed \space in the body of a document maybe once or twice (except when the text requires a description of the \space command itself).

The solution I propose does not differ in a substantial way from Manuel's, but it features a couple of differences, the main one being that \left and \right are good here, where the number of rows in a \cvect is unknown (it's two, here, but I guess it could be more).

A trick for getting a better transposition symbol when next to a parenthesis is to use \!.

Alignment between the label and the word “Answer” can be obtained with the help of enumitem.

\documentclass[titlepage]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{geometry}

\setkomafont{disposition}{\normalfont\bfseries}
\geometry{left=1in,right=1in,top=1in,bottom=1in}

\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{enumitem}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{class}
\fancyhead[R]{name}
\fancyfoot[C]{\thepage} %center of the footer!
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\newcommand{\cvect}[1]{\begin{bmatrix}#1\end{bmatrix}}
\newcommand{\nulldel}[1]{#1.\kern-\nulldelimiterspace}

\begin{document}

\begin{description}[leftmargin=1cm,itemindent=\labelsep]
\item[ii.] Calculate the covariance matrix of each class 
  (\(\Sigma_{1}, \Sigma_{2}\)) manually.\\*[\medskipamount]
Answer: \(
\begin{aligned}[t]
\Sigma_{1} = \frac{1}{2-1}\left\{ \vphantom{\cvect{0\\0}^{T}} \nulldel{\right}
  & \left(\cvect{0.80 \\ 1.2}-\cvect{1.0 \\ 1.375}\right)
    \left(\cvect{0.80 \\ 1.2}-\cvect{1.0 \\ 1.375}\right)^{\!T} + {} \\
  & \left(\cvect{0.90 \\ 1.4}-\cvect{1.0 \\ 1.375}\right)
    \left(\cvect{0.90 \\ 1.4}-\cvect{1.0 \\ 1.375}\right)^{\!T} + {} \\
  & \left(\cvect{0.90 \\ 1.4}-\cvect{1.0 \\ 1.375}\right)
    \left(\cvect{0.90 \\ 1.4}-\cvect{1.0 \\ 1.375}\right)^{\!T} + {} \\
  & \nulldel{\left} \left(\cvect{0.90 \\ 1.4}-\cvect{1.0 \\ 1.375}\right)
    \left(\cvect{0.90 \\ 1.4}-\cvect{1.0 \\ 1.375}\right)^{\!T}\, \right\}
\end{aligned} \)
\end{description}
\end{document}

enter image description here

1 If you found \subitem in some guide, dispose of the guide in the best way possible, which involves the trash can. ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.