0

I want to align the first line of margin par with the first line of the main text. How to set the vertical space exactly?

\documentclass[twoside,12pt]{article}
\usepackage[a4paper,marginparwidth=8cm,includemp,innermargin=4cm,outermargin=4cm]{geometry}
\usepackage{amsmath}

\begin{document}
\begin{enumerate}
    \item 
    \marginpar
    {
        \bigskip
        $\displaystyle
        \begin{aligned}[t]
            & \frac{A^m}{A^n} = A^{m-n}\\
            & A^0 = 1 \text{ where } A \ne 0
        \end{aligned}
        $
    }
    $\displaystyle
     \frac{\left(2a\right)^3 3a^\frac{1}{3}}{a^{-\frac{2}{3}}6a^2} = 2^2 \cdot a^2
    $
\end{enumerate}
\end{document}

enter image description here

1

I do not think that there is an exact value and believe that it would depend on the content. It is really hard to precisely align what is on the margins to what is in the main body because \marginnote command will usually prevent the ability of aligning contents that is provided in LaTeX environments or commands. This is usually due to nesting incompatibility or simply because primitive TeX instructions used to define environment may not apply equally to both main body contents and marginpar contents. However, here is a good way that is simple but also does not rely merely on trial and error to align the contents.

  1. To help align them systematically, we must add virtual contents to the smaller one of them, which is what is in the main body. Use \vphantom with the argument being the smaller contents (whether the one in the main text or in the margin)

$\displaystyle \frac{\left(2a\right)^3 3a^\frac{1}{3}}{a^{-\frac{2}{3}}6a^2} = 2^2 \cdot a^2 \vphantom{\displaystyle \begin{aligned}[c] & \frac{A^m}{A^n} = A^{m-n} \\ & A^0 = 1 \text{ where } A \ne 0 \end{aligned}}$

The output is then

enter image description here

  1. What is left now is to do some tuning. It is best to determine the offset in terms of the \baselineskip length. After some tuning, it was obvious that -0.1\baselineskip is the best offset. The content is now

enter image description here

This approach works even with different number of lines for the aligned environment.

enter image description here

What you need to do is to install virtual height to the shorter content using \vphantom where the argument of \vphantom is the larger content. By doing that, you will establish virtual boxes of equal heights and what would be left is to do some fine-tuning

\documentclass[twoside,12pt]{article}
\usepackage[a4paper,marginparwidth=8cm,includemp,innermargin=4cm,outermargin=4cm]{geometry}
\usepackage{amsmath}
\usepackage{adjustbox}
\usepackage{marginnote}

\begin{document}
    \begin{enumerate}
        \item 
        \marginnote{
    $\displaystyle
    \begin{aligned}[c]
    & \frac{A^m}{A^n} = A^{m-n} \\
    & A^0 = 1 \text{ where } A \ne 0
    \end{aligned}$}[-0.1\baselineskip]
    $\displaystyle \frac{\left(2a\right)^3 3a^\frac{1}{3}}{a^{-\frac{2}{3}}6a^2} = 2^2 \cdot a^2
        \vphantom{\displaystyle
            \begin{aligned}[c]
                & \frac{A^m}{A^n} = A^{m-n} \\
                & A^0 = 1 \text{ where } A \ne 0
            \end{aligned}}$
    \end{enumerate}
\end{document}

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.