4

When polyglossia is loaded noindentafter stops working:

\documentclass{article}
    \usepackage{fontspec}
        \setmainfont{Latin Modern Roman}
    \usepackage{lipsum}
    \usepackage{polyglossia}
        \setmainlanguage{french}
        %   \PolyglossiaSetup{french}{indentfirst=false}
    \usepackage{noindentafter}
        \NoIndentAfterEnv{myitemize}

    \newenvironment{myitemize}{\begin{itemize}}{\end{itemize}}

\begin{document}
   \begin{myitemize}
       \item test
   \end{myitemize}

   \lipsum
\end{document}

enter image description here

This happens with all the languages I tested. In No indent in the first paragraph in a section? egreg suggested to add indentfirst=false (commented in the code) but unfortunately it does not work for custom environments.

Is there a (possibly easy) way to restore the noindentafter functionality when usingpolyglossia?

d-cmst
  • 23,095
  • why noindentafter{myitemize} rather than the standard latex markup which is not to indent after a list if there is no new paragraph? – David Carlisle Nov 26 '13 at 20:49
  • @DavidCarlisle I need this for many different kinds of custom environments: tcolorboxes, tikzpictures, etc. – d-cmst Nov 26 '13 at 20:53
  • sure but a blank line meaning start of paragraph is deeply ingrained in latex and latex goes to lots of trouble to make that work even after a list. If you don't want to start a new paragraph, just don't insert a blank line. – David Carlisle Nov 26 '13 at 20:54
  • @DavidCarlisle But this does not work with tcolorboxes? I still get indented text. E.g. try: \begin{tcolorbox}test\end{tcolorbox}\lipsum – d-cmst Nov 26 '13 at 20:59
  • a display environment based on colorbox should be using a trivlist environment (like center and quote verbatim and ...) – David Carlisle Nov 26 '13 at 21:01
  • @DavidCarlisle as far as I understand default tcolorboxes have a \par at the end. – d-cmst Nov 26 '13 at 21:03
  • @DavidCarlisle this also does not work if you have a minipage of, say, 3cm. The text will go to the side of the minipage if you don't start a new paragraph. – d-cmst Nov 26 '13 at 21:08
  • a minipage is a horizontal mode construct, it is positioned like a letter, if you are defining a vertical mode display environment you should use the in built constructs for that (which is the list environment, basically) the main reason the center and similar environments use a list is to handle indents following the environment. – David Carlisle Nov 26 '13 at 21:35
  • @DavidCarlisle I see your point, but since I'm using tcolorboxes a lot, which have that \par by default at the end, and since I might be using something else in a unorthodox way, I find convenient to add stuff to \NoIndentAfterEnv and live happily after. Consider also that in this specific use case I'm porting an already written document to LuaLaTeX, so the damage is already done :) – d-cmst Nov 26 '13 at 21:46
  • that's OK Andrew's got the tick anyway:-) – David Carlisle Nov 26 '13 at 22:01

1 Answers1

4

Both packages are messing with \@afterindentfalse. Fortunately polyglossia stores the old version \@@fterindentfalse so we can just redefine the central command \NoIndentAfterThis to use the stored version.

Sample output

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\usepackage{lipsum}

\usepackage{polyglossia}
\setmainlanguage{french}

\usepackage{noindentafter}
\makeatletter
\renewcommand*{\NoIndentAfterThis}{\par\@@fterindentfalse\@afterheading}
\makeatother

\NoIndentAfterEnv{myitemize}
\newenvironment{myitemize}{\begin{itemize}}{\end{itemize}}

\begin{document}
Text. \NoIndentAfterThis Text.
\begin{myitemize}
\item test
\end{myitemize}

\lipsum
\end{document}
Andrew Swann
  • 95,762