cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
864 stars 84 forks source link

Exclude `table` and `tabular` from indentation #534

Closed reneas closed 4 months ago

reneas commented 4 months ago

original .tex code

\begin{table}[]
\centering
\caption{Stoffeigenschaften TiAl6V4}
\label{tab:stoffeigenschaften_TiAl6V4}
\begin{tabular}{@{}lrrrr@{}}
\toprule
Eigenschaft                 & TiAl6V4    & Inconel 718 & Aluminium 7075 & Einheit           \\ \midrule
Härte                       & 300-400    & -           & -              & HV                \\
E-Modul                     & 110 - 140  & 205         & 72             & GPa               \\
Zugfestigkeit $R_m$         & 900 - 1200 & 1230        & 360 – 540      & MPa               \\
Dehngrenze $R_p_{0,2}$      & 800 - 1100 & 1030        & 220 – 470      & MPa               \\
Bruchdehnung                & 13-16      & 12          & 1-6            & \%                \\
Dichte                      & 4,42       & 8,2         & 2,8            & $\frac{kg}{dm^3}$ \\
Schmelztemperatur           & 1648       & 1260-1336   & 477-638        & °C                \\
Wärmeleitfähigkeit bei 20°C & 6,7        & 11,5        & 130-160        & $\frac{W}{m*K}$   \\ \bottomrule
\end{tabular}
\end{table}

yaml settings

default settings + the ones from issue #523

actual/given output

\begin{table}[]
    \centering
    \caption{Stoffeigenschaften TiAl6V4}
    \label{tab:stoffeigenschaften_TiAl6V4}
    \begin{tabular}{@{}lrrrr@{}}
        \toprule
        Eigenschaft                 & TiAl6V4    & Inconel 718 & Aluminium 7075 & Einheit           \\ \midrule
        Härte                       & 300-400    & -           & -              & HV                \\
        E-Modul                     & 110 - 140  & 205         & 72             & GPa               \\
        Zugfestigkeit $R_m$         & 900 - 1200 & 1230        & 360 – 540      & MPa               \\
        Dehngrenze $R_p_{0,2}$      & 800 - 1100 & 1030        & 220 – 470      & MPa               \\
        Bruchdehnung                & 13-16      & 12          & 1-6            & \%                \\
        Dichte                      & 4,42       & 8,2         & 2,8            & $\frac{kg}{dm^3}$ \\
        Schmelztemperatur           & 1648       & 1260-1336   & 477-638        & °C                \\
        Wärmeleitfähigkeit bei 20°C & 6,7        & 11,5        & 130-160        & $\frac{W}{m*K}$   \\ \bottomrule
    \end{tabular}
\end{table}

it does what it's supposed to do, but in my vscode it looks like this because of the linebreaks: image

desired output

Same as original TeX code. I don't want them to be indented, because i have linebreaks at a specific line and it destroys the formatting. the tables become unreadable in my editor.

anything else

maybe there is another way of solving this but the easiest way for me would be to disable indentation of table and tabular

cmhughes commented 4 months ago

Can you try

noAdditionalIndent:
    table: 1
    tabular: 1
reneas commented 4 months ago

That worked thanks for the quick reply :) I'm sorry if I'm asking these super simple questions but the program structure is a bit too complicated for me...

cmhughes commented 4 months ago

If you can help make it better, feel free to contribute!

On Wed, 3 Apr 2024, 14:52 Hannez Kannez, @.***> wrote:

That worked thanks for the quick reply :) I'm sorry if I'm asking these super simple questions but the program structure is a bit too complicated for me...

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/534#issuecomment-2034679702, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYGROTSB2R6SWKCRKALY3QCTPAVCNFSM6AAAAABFTKHXPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZUGY3TSNZQGI . You are receiving this because you commented.Message ID: @.***>