3

I have this code

\documentclass{article}
\usepackage{amsmath,amssymb,geometry}

\geometry{
    paper=a4paper,
    left=2cm,
    right=2cm,
    vmargin=2cm,
    includeheadfoot=true,
    headheight=35pt
}

\begin{document}
    \begin{align}
        D_x &= \mathbb{R}, &D_y &= \mathbb{R} \symbol{92} \{0\} \notag\\
        \implies D_f &= \mathbb{R} \symbol{92} \{0\}\notag\\
        dx &= 8tdt, &dy &= \left(3t^2 - \frac{14}{t}\right)dt,\label{eq3}\\
        \implies\frac{dy}{dx} &= \frac{3t^3-14}{8t^2}
        \implies d\left(\frac{dy}{dx}\right)
        = \left(\frac{3}{8} + \frac{7}{2t^3}\right)dt \label{eqf''}\\
        \lim_{t \to 0} x &= -3, &\lim_{t \to 0} y &= +\infty,\label{eq2}\\
    \end{align}
\end{document}

which produces this

However I want this, where line 2 and 4 is centered

3
  • Please always show a minimal working example starting with \documentclass, loading all required packages and ending with \end{document}. Code snippets always need guessing and therefore easily can result in not useful answers. And code snippets often need extra effort to get a working example that is needed to reproduce the problem and the shown result.
    – cabohah
    Nov 21, 2023 at 8:02
  • 2
    I'd suggest to rethink the way of presenting things. Alignment here is the less important part: you want to add words that describe what you're doing.
    – egreg
    Nov 21, 2023 at 8:18
  • Off-topic: (a) Don't use \symbol{92} directly, as it won't generate the proper spacing. Instead, use \setminus. (b) left=2cm, right=2cm, vmargin=2cm may be expressed more succinctly as margin=2cm.
    – Mico
    Nov 21, 2023 at 11:36

3 Answers 3

1

Create a third column and use \mathclap (or \mathmakebox[2in][c]), from the mathtools package

\begin{align}
    D_x &= \mathbb{R}, &&&D_y &= \mathbb{R} \symbol{92} \{0\} \notag\\
    &&\mathmakebox[2in][c]{
        \implies D_f = \mathbb{R} \symbol{92} \{0\}
        }\notag\\
    dx &= 8tdt, &&&dy &= \left(3t^2 - \frac{14}{t}\right)dt,\label{eq3}\\
    &&\mathmakebox[2in][c]{
        \implies\frac{dy}{dx} = \frac{3t^3-14}{8t^2}
        \implies d\left(\frac{dy}{dx}\right)
        = \left(\frac{3}{8} + \frac{7}{2t^3}\right)dt
    }\\
    \lim_{t \to 0} x &= -3, &&&\lim_{t \to 0} y &= +\infty,\label{eq2}
\end{align}

This gives the following output output of given latex code

The command \mathclap puts its argument in a zero width box and centers it. [2, 3.1.1]

The \mathmakebox[width][alignment]{content} command makes a box and puts content inside it. It takes an optional argument width and another (additional) optional argument alignment which could be l, r or c.

See also: \shoveright and \shoveleft.

2
  • can the distance between each 2 expressions be not so wide?
    – Le_Square
    Nov 21, 2023 at 10:12
  • Adjust the width argument of mathmakebox to a smaller value like 0in. Alternatively, replace \mathmakebox[2in][c] with \mathclap. Nov 21, 2023 at 10:27
0

Ugly hack:

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsfonts}

\begin{document}
\begin{align}
    D_x &= \mathbb{R}, &D_y &= \mathbb{R} \symbol{92} \{0\} \notag\\
    \intertext{\centerline{$\displaystyle\implies D_f = \mathbb{R} \symbol{92} \{0\}$}}
    dx &= 8tdt, &dy &= \left(3t^2 - \frac{14}{t}\right)dt,\label{eq3}\\
    \intertext{\centerline{$\displaystyle\implies\frac{dy}{dx} = \frac{3t^3-14}{8t^2}
    \implies d\left(\frac{dy}{dx}\right)
    = \left(\frac{3}{8} + \frac{7}{2t^3}\right)dt$}} \notag\\[-43pt]\label{eqf''}\\[14pt]
    \lim_{t \to 0} x &= -3, &\lim_{t \to 0} y &= +\infty,\label{eq2}
\end{align}

\end{document}

enter image description here

2
  • can the spacing between the lines be not so wide?
    – Le_Square
    Nov 21, 2023 at 10:11
  • @Le_Square You can always use the optional argument of \\ to change the vertical spaces manually. To change it globally for all align environment, please ask a new question (if there isn't already one). But I wouldn't reduce it. This would have negative influence to the readability. It is already hard to read now.
    – cabohah
    Nov 21, 2023 at 10:40
0

I would like to recommend that you apply a radical visual simplification and go for a single-column, left-aligned "look".

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb,geometry}
\geometry{a4paper, margin=2cm, includeheadfoot, headheight=35pt}

\counterwithin{equation}{section} % just for this example

\begin{document}
\setcounter{section}{1} % just for this example
\stepcounter{equation}

\begin{align}
  & D_x = \mathbb{R}, \quad D_y = \mathbb{R} \setminus \{0\} \notag\\[2\jot]
  \implies & D_f = \mathbb{R} \setminus \{0\}\notag\\
  & dx = 8t\,dt, \quad dy = \Bigl(3t^2 - \frac{14}{t} \Bigr)dt,\label{eq3}\\
  \implies & \frac{dy}{dx} = \frac{3t^3-14}{8t^2}
  \implies d\biggl(\frac{dy}{dx}\biggr)
  = \biggl(\frac{3}{8} + \frac{7}{2t^3}\biggr)dt \label{eqf''} \\[\jot]
  & \lim_{t \to 0} x = -3, \quad \lim_{t \to 0} y = +\infty,\label{eq2}
\end{align}
\end{document}

You must log in to answer this question.

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