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 usually use subsection environments to write sub questions for a big question. It usually works well as shown in the first example below. However, I encountered an error for the second example below.

Error Message: ! Argument of \@sect has an extra }.

I guess the problem is with the formula and the length. Could anyone tell me how to solve this problem, please? Thank you!

Example 1

\subsection{Proceed with the integration in $L(\mu, \sigma^2_a, \sigma^2)$ to determine the likelihood.}

Example 2

\subsection{Show that the log-likelihood for the data can be written as:
\begin{eqnarray*}
\log L &=&  -\frac{N}{2} \log 2 \pi  - \frac{1}{2} m  \log(\sigma^2 + n \sigma^2_a) - \frac{1}{2} (N-m) \log \sigma^2  \\
&& - \frac{1}{2 \sigma^2} \sum_i \sum_j  (X_{ij} - \mu)^2 + \frac{\sigma^2_a n^2}{2\sigma^2 (\sigma^2 + n \sigma^2_a)} \sum_i^m (\overline{X}_{i\cdot} - \mu)^2,
\end{eqnarray*}
where $\overline{X}_{i\cdot} = \sum_{j=1}^n \frac{X_{ij}}{n}$.}
share|improve this question
1  
The only reason for this is that you want it bold (perhaps a bit larger) and numbered, right? There are better ways of doing this. Also see eqnarray vs align suggesting to avoid the use of eqnarray. There are better ways of doing that as well. –  Werner May 2 at 7:21
    
@Werner Thank you for your response. Could you suggest me some better ways please? –  LaTeXfan May 2 at 7:25

2 Answers 2

up vote 5 down vote accepted

Here is a very elementary example that uses a question and subquestion environment to set something similar to what you might be after:

enter image description here

\documentclass{article}
\usepackage{environ,amsmath}
\newcounter{question}
\newcounter{subquestion}
\numberwithin{subquestion}{question}
%\renewcommand{\thesubquestion}{.\arabic{subequation}}
\NewEnviron{question}{%
  \refstepcounter{question}%
  \noindent\bfseries \thequestion.\quad%
  \ignorespaces\BODY
}
\NewEnviron{subquestion}{%
  \refstepcounter{subquestion}%
  \noindent\bfseries \thesubquestion.\quad%
  \ignorespaces\BODY
}
\begin{document}
\begin{question}
Proceed with the integration in $L(\mu, \sigma^2_a, \sigma^2)$ to determine the likelihood.
\end{question}

\bigskip

\begin{subquestion}
Show that the log-likelihood for the data can be written as:
\begin{align*}
  \log L &= -\tfrac{N}{2} \log 2 \pi - \tfrac{1}{2} m \log\bigl(\sigma^2 + n \sigma^2_a\bigr) - \tfrac{1}{2} (N-m) \log \sigma^2 \\
  &\phantom{{}={}} \quad - \tfrac{1}{2 \sigma^2} \sum_i \sum_j  \bigl(X_{ij} - \mu\bigr)^2 + \frac{\sigma^2_a n^2}{2\sigma^2 (\sigma^2 + n \sigma^2_a)} 
    \sum_i^m (\overline{X}_{i\cdot} - \mu)^2,
\end{align*}
where $\overline{X}_{i\cdot} = \sum_{j = 1}^n \frac{X_{ij}}{n}$.
\end{subquestion}
\end{document}

The use of an environment is not all that important here, and could be replaced with something smaller. However, without the proper context as a whole, this should suffice.


Your original problem stemmed from the fact that sectional units contain a movable argument, and your use of big math-like constructions is not wanted in those. However, the use of \section and \subsection for questions does not provide the same contextual reference as (say) \question and \subquestion.

share|improve this answer

I think your posting raises two separate issues: First, how to use bold-math for small formulae inside a sectioning header and second, how to deal with very long sectioning headers that contain complicated math material, such as a two-line equation.

The first issue may be dealt with by loading the bm ("bold math") package and encasing the math material in a sectioning header in a \bm{...} instruction.

AFAICT, the second issue can only be dealt with satisfactorily by removing the entire two-line equation from the sectioning header and placing it in the body of the text. By the way, the eqnarray environment is severely deprecated. It's much better to use an environment such as align, provided by the amsmath package.

enter image description here

\documentclass{article}
\usepackage{amsmath}  % for align* environment
\usepackage{bm}       % for \bm macro
\begin{document}
\section{Two assignments}

\subsection{Proceed with the integration in $\bm{L(\mu, \sigma^2_a, \sigma^2)}$ 
  to determine the likelihood}

\subsection{Show that the log-likelihood function can be written in a specific form}

Show that the log-likelihood function can be written as follows:
\begin{align*}
    \log L &=  -\frac{N}{2} \log 2 \pi  - \frac{1}{2} m  \log(\sigma^2 + n \sigma^2_a) 
      - \frac{1}{2} (N-m) \log \sigma^2  \\
    &\qquad - \frac{1}{2 \sigma^2} \sum_i \sum_j  (X_{ij} - \mu)^2 + 
      \frac{\sigma^2_a n^2}{2\sigma^2 (\sigma^2 + n \sigma^2_a)} 
      \sum_i^m (\bar{X}_{i\cdot} - \mu)^2,
\end{align*}
where $\bar{X}_{i\cdot} = \frac{1}{n}\sum_{j=1}^n X_{ij}$.
\end{document}
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.