auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange formatting


From: Arash Esbati
Subject: Re: strange formatting
Date: Sat, 07 Jan 2023 16:11:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50

Artemio González López <artemiog@mac.com> writes:

> I’ve been having some problems with auctex formatting of some
> equations. Here’s a minimal example:
>
> \documentclass[a4paper,11pt]{article}
>
> \usepackage{babel}
> \usepackage{amsmath}
>
> \begin{document}
>
> \[
>   I_O=Ml^2\begin{pmatrix}
>             \frac1{12}& 0& 0\\[2pt]
>             0& \frac1{12}& 0\\[2pt]
>             0& 0& \frac16
>           \end{pmatrix}+Ml^2
>           \begin{pmatrix}
>             \hfill\frac14& -\frac14& 0\\[2pt]
>             -\frac14& \hfill\frac14& 0\\[2pt]
>             \hfill 0& \hfill 0& \frac12
>           \end{pmatrix}=Ml^2
>           \begin{pmatrix}
>             \hfill\frac13& -\frac14& 0\\[2pt]
>             -\frac14& \hfill\frac13& 0\\[2pt]
>             \hfill0& \hfill0& \frac23
>           \end{pmatrix}
>         \]
>         
>       \end{document}
>
> After the equation all text is aligned with the closing \[, which is a
> pain. Is this reproducible? And, more importantly, how could I fix it?

Yes, I can reproduce this.  I think your best bet is to have \begin|\end
statements in their own line and format your input like this:

\[
  I_O=Ml^2
  \begin{pmatrix}
    \frac1{12}     & 0              & 0 \\[2pt]
    0              & \frac1{12}     & 0 \\[2pt]
    0              & 0              & \frac16
  \end{pmatrix}
  +Ml^2
  \begin{pmatrix}
    \hfill\frac14  & -\frac14       & 0 \\[2pt]
    -\frac14       & \hfill\frac14  & 0 \\[2pt]
    \hfill 0       & \hfill 0       & \frac12
  \end{pmatrix}
  =Ml^2
  \begin{pmatrix}
    \hfill\frac13  & -\frac14       & 0 \\[2pt]
    -\frac14       & \hfill\frac13  & 0 \\[2pt]
    \hfill0        & \hfill0        & \frac23
  \end{pmatrix}
\]

The alignment of '&' is of course unnecessary and was simply done by
`align-regexp'.

Best, Arash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]