Multicols: How to center two cols?

1,976

Solution 1

The tasks environment is done for that, as the numbering will be from left to right first, then vertical, whereas multicol does the converse. I took the opportunity to correct your code: nowadays, the language option from babel should be loaded as an option of the document class. Note amscd should be replaced with tikz-cd, as it yields better results.

\documentclass[a4paper, brazil, 12pt]{report}
\usepackage{amsmath, amsfonts, amscd, bezier}
\usepackage{amssymb}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[dvips]{graphicx}
%\usepackage{pdfsync}
\usepackage{color}
\usepackage{hyperref}
\usepackage{tasks}

\newcommand{\ds}{\displaystyle}
\newcommand{\pr}{\hspace*{1.5cm}}

\DeclareMathOperator{\sen}{sen}
\DeclareMathOperator{\senh}{senh}
\DeclareMathOperator{\arcsen}{arcsen}
\DeclareMathOperator{\tg}{tg}
\DeclareMathOperator{\arctg}{arctg}
\DeclareMathOperator{\cotg}{cotg}
\DeclareMathOperator{\arccotg}{arccotg}
\DeclareMathOperator{\arcsec}{arcsec}
\DeclareMathOperator{\cossec}{cossec}
\DeclareMathOperator{\arccossec}{arccossec}

\begin{document}

\pagestyle{myheadings} \thispagestyle{empty}
    \begin{tasks}(2)
        \task $f (x) = \begin{cases}
        \ds x\sen\dfrac{1}{x}, & \hbox{ se } x \neq 0\\
        0, & \hbox{ se } x = 0
        \end{cases} $ %\quad \quad
        \task $f (x) = \begin{cases}
        \ds x^2\sen\dfrac{1}{x}, & \hbox{ se } x \neq 0\\
        0, & \hbox{ se } x = 0
        \end{cases} $
    \end{tasks}

\end{document} 

enter image description here

Solution 2

Now that you have provided the real setup with used packages, I can confirm that the real cause of this white space above the first column is due to the pdfsync package. It somehow conflicts with the column balancing routines of multicol. As @egreg once said: "don't use pdfsync for any reason whatsoever". Also, \quad \quad is meaningless here, just remove it.

\documentclass[a4paper,12pt]{report}
\usepackage{amsmath,amsfonts,amscd,bezier}
\usepackage{amssymb}
\usepackage[brazil]{babel}
\usepackage[latin1]{inputenc}
\usepackage[dvips]{graphicx}
%\usepackage{pdfsync}
\usepackage{color}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage{multicol}

\newcommand{\ds}{\displaystyle}
\newcommand{\pr}{\hspace*{1.5cm}}
\newcommand{\sen}{{\mbox{sen\,}}}

\DeclareMathOperator{\senh}{senh}
\DeclareMathOperator{\arcsen}{arcsen}
\DeclareMathOperator{\tg}{tg}
\DeclareMathOperator{\arctg}{arctg}
\DeclareMathOperator{\cotg}{cotg}
\DeclareMathOperator{\arccotg}{arccotg}
\DeclareMathOperator{\arcsec}{arcsec}
\DeclareMathOperator{\cossec}{cossec}
\DeclareMathOperator{\arccossec}{arccossec}  

\begin{document}
\pagestyle{myheadings} \thispagestyle{empty}

\begin{multicols}{2}
    \begin{enumerate}[(a)]
        \item $f (x) = \begin{cases}
        \ds x\sen\dfrac{1}{x}, & \hbox{ se } x \neq 0\\
        0, & \hbox{ se } x = 0
        \end{cases} $ %\quad \quad
        \item $f (x) = \begin{cases}
        \ds x^2\sen\dfrac{1}{x}, & \hbox{ se } x \neq 0\\
        0, & \hbox{ se } x = 0
        \end{cases} $
    \end{enumerate}
\end{multicols}

\end{document}

enter image description here

Share:
1,976

Related videos on Youtube

Moura
Author by

Moura

Updated on October 21, 2020

Comments

  • Moura
    Moura about 3 years

    I'm sorry by my poor English. Thanks for any help. Here is my question:

    I would like to center two expressions by using the multicols and enumerate commands, just like this: enter image description here

    Unfortunately the command I am using is producing this: enter image description here

    Here is my commands:

    \documentclass[a4paper,12pt]{report}
    \usepackage{amsmath,amsfonts,amscd,bezier}
    \usepackage{amssymb}
    \usepackage[brazil]{babel}
    \usepackage[latin1]{inputenc}
    \usepackage[dvips]{graphicx}
    \usepackage{pdfsync}
    \usepackage{color}
    \usepackage{hyperref}
    \usepackage{enumerate}
    \usepackage{multicol}
    
    \newcommand{\ds}{\displaystyle}
    \newcommand{\pr}{\hspace*{1.5cm}}
    \newcommand{\sen}{{\mbox{sen\,}}}
    
    \DeclareMathOperator{\senh}{senh}
    \DeclareMathOperator{\arcsen}{arcsen}
    \DeclareMathOperator{\tg}{tg}
    \DeclareMathOperator{\arctg}{arctg}
    \DeclareMathOperator{\cotg}{cotg}
    \DeclareMathOperator{\arccotg}{arccotg}
    \DeclareMathOperator{\arcsec}{arcsec}
    \DeclareMathOperator{\cossec}{cossec}
    \DeclareMathOperator{\arccossec}{arccossec}
    
    
    
    \begin{document}
    \pagestyle{myheadings} \thispagestyle{empty}
    
    \begin{multicols}{2}
        \begin{enumerate}[(a)]
            \item $f (x) = \begin{cases}
            \ds x\sen\dfrac{1}{x}, & \hbox{ se } x \neq 0\\
            0, & \hbox{ se } x = 0
            \end{cases} $ \quad \quad
            \item $f (x) = \begin{cases}
            \ds x^2\sen\dfrac{1}{x}, & \hbox{ se } x \neq 0\\
            0, & \hbox{ se } x = 0
            \end{cases} $
        \end{enumerate}
    \end{multicols}
    
    \end{document}
    

    I'm sorry, I could not explain it right. Items (a) and (b) I would like to be centered and aligned horizontally on the same line, like that de first figure. Item (b) is higher than item (a) (the second figure).

    • Bernard
      Bernard about 6 years
      You want to centre each expression w.r.t. what?
    • Ignasi
      Ignasi about 6 years
      Could you show a complete example and not only some fragment? What class are you using? how is \ds defined? ...
    • Moura
      Moura about 6 years
      \ds is \displaystyle and \sen is \sin (in portuguese)
    • AboAmmar
      AboAmmar about 6 years
      ,@Moura - The problem can be solved at a glance, but without giving the required information about your real document setup (class, single/double column, commands before/after ...) you are unlikely to get any good answer.
  • Moura
    Moura about 6 years
    Is the problem \usepackage{pdfsync} ? It is working now. Thanks a lot