1

I want to get rid of the space in the last equation. But I don't know how.

\documentclass{article}

\usepackage{amsmath}
\usepackage{multicol}

\newcounter{NC}

\begin{document}

\begin{multicols}{2}
\begin{enumerate}
\setcounter{enumi}{\value{NC}}
\item $\displaystyle \int_0^\pi \sin^2 x\;dx$
\item $\displaystyle \int_0^\frac{\pi}{4}\tan^2\theta\;d\theta$
\setcounter{NC}{\value{enumi}}
\end{enumerate}
\end{multicols}

\smallskip

\begin{multicols}{2}
\begin{enumerate}
\setcounter{enumi}{\value{NC}}
\item $\displaystyle \int_0^\frac{\pi}{4} \cos^4 x\;dx; \quad \quad \rm{Note:\;}\tan' (x) = 1+\tan^2 x = \frac{1}{\cos^2 x}$
\setcounter{NC}{\value{enumi}}
\end{enumerate}
\end{multicols}

\end{document} 

enter image description here

5
  • Why do you place the third \item in a multicols{2} environment if you don't want a column break to occur?
    – Mico
    Oct 21, 2023 at 23:04
  • @Mico: thanks a lot for formatting my code. But I still don't know how to format it
    – Rafiq
    Oct 21, 2023 at 23:04
  • @Mico: I have a lot of integrals that I want to display in multicol environment, and keeping the horizontal numbering.
    – Rafiq
    Oct 21, 2023 at 23:06
  • 1
    \rm is not defined by default in latex. some classes define it for compatibility with documents from the 1980's but it does not take an argument, so \rm{Note:\;} applies to the rest of the expression, not to Note: Oct 21, 2023 at 23:48
  • @David Carlisle: Thanks. I keep learning from all of you guys.
    – Rafiq
    Oct 21, 2023 at 23:56

2 Answers 2

1

If you want to suppress automatic column balancing, which is what's causing the apparently unwanted column break in the second multicols environment, you need to use a multicols* environment, not a multicols environment.

Some addtional points:

  • Writing \int_0^\frac{\pi}{4} is an accident waiting to happen. Please write \int_0^{\frac{\pi}{4}}.

  • I would place Note: $\tan'(x) = 1+\tan^2 x = 1/\cos^2 x$ on a line after the line generated by \item $\displaystyle \int_0^{\frac{\pi}{4}} \cos^4 x\;dx$.

  • The code shown below provides a method that automates incrementing the NC counter. I would also load the enumitem package and use its \setlist macro to instruct LaTeX to not indent the numbers generated by \item. Tnis may come in handy in two-column layouts.


enter image description here

\documentclass{article}
\usepackage{amsmath,multicol}
\newcounter{NC}

% New:
\usepackage{enumitem}
\setlist[enumerate]{left=0pt} % save some horizontal space

\usepackage{etoolbox} % for '\apptocmd' macro
\usepackage{ragged2e} % for '\RaggedRight' macro
\apptocmd{\item}{\stepcounter{NC}\RaggedRight}{}{}

\begin{document}

\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle \int_0^\pi \sin^2 x\,dx$
\item $\displaystyle \int_0^{\frac{\pi}{4}}\tan^2\theta\,d\theta$
\end{enumerate}
\end{multicols}

\smallskip

\begin{multicols*}{2}
\begin{enumerate}
\setcounter{enumi}{\value{NC}}
\item $\displaystyle \int_0^{\frac{\pi}{4}}\cos^4x\,dx$

Note: $\tan'(x) = 1+\tan^2x = 1/\cos^2x$.
\end{enumerate}
\end{multicols*}

\end{document} 
3
  • 1
    Thank you very much. I'll study thoroughly your answer and take all of it in account if I digest it, because I'm still a beginner.
    – Rafiq
    Oct 21, 2023 at 23:33
  • I would guess @Rafiq doesn't need NC at all, and can use enumitem option resume ro restart the enumerate where the last one finished. Oct 21, 2023 at 23:53
  • @DavidCarlisle - That would be my guess too, actually. Howver, I don't think the resume option works as expected if the enumerate items are encased (entombed?) in multicols environments.
    – Mico
    Oct 21, 2023 at 23:59
1

No multicols, it's not the right tool. I suggest an array instead.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\usepackage{showframe}% just to show the page margins

\begin{document}

\begin{center}
\setlength{\arraycolsep}{0pt}
$\begin{array}{
  >{\displaystyle}w{l}{0.5\columnwidth}
  >{\displaystyle}w{l}{0.5\columnwidth}
}
\text{1. } \int_0^\pi \sin^2 x\,dx &
\text{2. } \int_0^\frac{\pi}{4}\tan^2\theta\,d\theta
\\[4ex]
\text{3. } \int_0^\frac{\pi}{4} \cos^4 x\,dx &
\hspace*{\fill}\text{Note: } \tan' (x) = 1+\tan^2 x = \frac{1}{\cos^2 x}
\end{array}$
\end{center}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .