sylvainhalle / textidote

Spelling, grammar and style checking on LaTeX documents
https://sylvainhalle.github.io/textidote
GNU General Public License v3.0
945 stars 69 forks source link

How to do correct subsection/paragraph titles? #184

Open MatthiasLohr opened 3 years ago

MatthiasLohr commented 3 years ago

I'm struggling with providing subsection/paragraph titles where texttidote does not complain. Currenty, I'm getting the following errors:

* L103C18-L103C18 Please add a punctuation mark at the end of paragraph. 
  Suggestions: [Structure., Structure!, Structure?, Structure:, Structure,, 
  Structure;] (5240) [lt:en:PUNCTUATION_PARAGRAPH_END] 
  \paragraph{Paper Structure}
                   ^
* L124C18-L124C18 Please add a punctuation mark at the end of paragraph. 
  Suggestions: [Exchange., Exchange!, Exchange?, Exchange:, Exchange,, 
  Exchange;] (6393) [lt:en:PUNCTUATION_PARAGRAPH_END] 
  \subsection{Fair Exchange}
                   ^
* L137C18-L137C18 Please add a punctuation mark at the end of paragraph. 
  Suggestions: [Theory., Theory!, Theory?, Theory:, Theory,, Theory;] (7013) 
  [lt:en:PUNCTUATION_PARAGRAPH_END] 
  \subsection{Game Theory}
                   ^

When I add a period at the end of the headlines (which seems to be odd in scientific documents) I'm getting the following:

* L103C1-L103C1 A paragraph heading should not end with a punctuation symbol. 
  [sh:008] 
  \paragraph{Paper Structure.}
  ^
* L124C1-L124C1 A section title should not end with a punctuation symbol. 
  [sh:002] 
  \subsection{Fair Exchange.}
  ^
* L137C1-L137C1 A section title should not end with a punctuation symbol. 
  [sh:002] 
  \subsection{Game Theory.}
  ^

Removing the periods obviously ends up in the upper errors...

Am I missing something here?

MatthiasLohr commented 3 years ago

Additional info: For some reason, it does not seem to be complaining about all sections etc. For example, \section{Related Work} is fine for textidote. Single word section/subsection/paragraph titles are also ok.

sylvainhalle commented 3 years ago

This is caused by the fact that "basic" rules see the whole document with the LaTeX markup, so they know that a piece of text is a section heading. In contrast, the grammar checker must be passed a cleaned-up version with only plain text, so it treats every heading as a normal paragraph.

I don't know how to instruct the LanguageTool checker to see portions of text as headings and stop issuing warnings about punctuation. (Ideas anyone?) For this reason I'll mark this issue both as help wanted.

The best I can suggest for the moment is to disable one of the two rules (or both) using the --ignore command line switch.

MatthiasLohr commented 3 years ago

Thank you for you reply!

In contrast, the grammar checker must be passed a cleaned-up version with only plain text, so it treats every heading as a normal paragraph.

But why are \section commands then fine? I only have the problem with subsection, subsubsection and paragraph.

The best I can suggest for the moment is to disable one of the two rules (or both) using the --ignore command line switch.

Thanks for this idea. However, I was thinking about if replacement rules could be used to just remove subsections/paragraphs completely from the text. However, my replacement rule for that does not have to seem any effect...

\\paragraph\{[\sa-zA-Z]+\}  Replaced.
\\subsection\{[\sa-zA-Z]+\} Replaced.
sylvainhalle commented 3 years ago

On my side, all levels of headings produce the same effect, even \section.

The replacement rules you suggest are an excellent workaround until a longer-term solution is found. Thanks for the suggestion!