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

Indenting doesn't happen, on the opposite it !indents. #519

Closed StormLord07 closed 5 months ago

StormLord07 commented 6 months ago

original .tex code

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[russian]{babel}

\usepackage[left=30mm, top=20mm, right=15mm, bottom=20mm]{geometry}
\usepackage{titlesec}
\usepackage{indentfirst}
\setlength{\parindent}{1.25cm}
\linespread{1.5}
\usepackage{enumitem}
\setlist{nolistsep}

\usepackage{amsmath, amsfonts, amssymb}
\usepackage{graphicx} 
\usepackage{tabularx, longtable} 
\usepackage{listings} 
\usepackage{hyperref}
\usepackage{csquotes}
\usepackage[backend=biber, style=gost-numeric]{biblatex} 

\addbibresource{references.bib} 

\titleformat{\section}[block]{\bfseries\normalsize}{\thesection}{1em}{}
\titleformat{\subsection}[block]{\bfseries\normalsize}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{\bfseries\normalsize}{\thesubsubsection}{1em}{}

\begin{document}

\title{Название}
\author{Имя Фамилия}
\date{2023}

\maketitle

\tableofcontents
\newpage

\section{Введение}
\subsection{Актуальность}
Текст Введения очень долгий и длинный который повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется 

\section{Основная часть}
\subsection{Раздел 1}
Текст\dots

\subsection{Раздел 2}
Текст\dots

\section{Заключение}
Текст заключения\dots

\printbibliography{}

\end{document}

yaml settings

I use(told to use) the defaults.

actual/given output

The output is exactly the same as input, even if I add manually indents it just resets to all on left alignment. If there is a lot of text on one line, it doesn't separate it into multiple lines.

desired or expected output

I was expecting something like this:

...
\begin{document}

    \title{Название}
    \author{Имя Фамилия}
    \date{2023}

    \maketitle

    \tableofcontents
    \newpage

    \section{Введение}
        \subsection{Актуальность}
            Текст Введения очень долгий и длинный который повторяется повторяется повторяется повторяется повторяется 
            повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется 

    \section{Основная часть}
        \subsection{Раздел 1}
            Текст\dots

        \subsection{Раздел 2}
            Текст\dots

    \section{Заключение}
        Текст заключения\dots

    \printbibliography{}

\end{document}

anything else

It may be because of Russian and usage of utf-8? But I'm not sure, changing everything to English doesn't seem to work, one time changing the document to center did something but I can't reproduce it.

Specs

Windows 10,

This is perl 5, version 32, subversion 0 (v5.32.0) built for MSWin32-x64-multi-thread

Copyright 1987-2020, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
3.23.6, 2024-01-17
latexindent.pl lives here: C:/Users/pasha/AppData/Local/Programs/MiKTeX/scripts/latexindent/latexindent.pl
defaultSettings.yaml lives here C:/Users/pasha/AppData/Local/Programs/MiKTeX/scripts/latexindent/defaultSettings.yaml
project home: https://github.com/cmhughes/latexindent.pl
[15:49:25.982][Format][TeX] Formatting LaTeX. The command is C:\Users\user\Downloads\latexindent\bin\windows\latexindent.exe:["-c","c:/Users/user/Desktop/Diploma Tex/NIR1/","c:/Users/user/Desktop/Diploma Tex/NIR1/__latexindent_temp_main.tex","-y=defaultIndent: '    '"].
[15:49:26.687][Format][TeX] Formatted %WS1%\1\main.tex
or
latexindent main.tex -o main1.tex

same result

cmhughes commented 6 months ago

Please use the issue template

StormLord07 commented 6 months ago

Please use the issue template

Updated the Issue, kinda missunderstood how to use the template, i just replaced the sections with my text, sorry.

cmhughes commented 6 months ago

using the following

defaultIndent: "  "

noAdditionalIndent:
  document: 0

indentAfterHeadings:
  section:
    indentAfterThisHeading: 1
    level: 3
  subsection:
    indentAfterThisHeading: 1
    level: 4
  subsection*:
    indentAfterThisHeading: 0
    level: 4

gives

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[russian]{babel}

\usepackage[left=30mm, top=20mm, right=15mm, bottom=20mm]{geometry}
\usepackage{titlesec}
\usepackage{indentfirst}
\setlength{\parindent}{1.25cm}
\linespread{1.5}
\usepackage{enumitem}
\setlist{nolistsep}

\usepackage{amsmath, amsfonts, amssymb}
\usepackage{graphicx} 
\usepackage{tabularx, longtable} 
\usepackage{listings} 
\usepackage{hyperref}
\usepackage{csquotes}
\usepackage[backend=biber, style=gost-numeric]{biblatex} 

\addbibresource{references.bib} 

\titleformat{\section}[block]{\bfseries\normalsize}{\thesection}{1em}{}
\titleformat{\subsection}[block]{\bfseries\normalsize}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{\bfseries\normalsize}{\thesubsubsection}{1em}{}

\begin{document}

  \title{Название}
  \author{Имя Фамилия}
  \date{2023}

  \maketitle

  \tableofcontents
  \newpage

  \section{Введение}
   \subsection{Актуальность}
     Текст Введения очень долгий и длинный который повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется повторяется

  \section{Основная часть}
   \subsection{Раздел 1}
     Текст\dots

   \subsection{Раздел 2}
     Текст\dots

  \section{Заключение}
   Текст заключения\dots

   \printbibliography{}

\end{document}

see https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#lst-indentafterheadings

cmhughes commented 5 months ago

Let me know if you need anything else on this.