2

I would like to disable the automatic paragraph inside my thesis abstract which is called resumo. On the question How to disable new paragraph at empty line? they said I could use \let\par\relax to disable paragraphs, but if I do so:

\documentclass{abntex2}

% How to disable automatic indentation on new paragraphs?
% https://tex.stackexchange.com/questions/14375/how-to-disable-automatic-indentation
%
% Changing font size in an example environment
% https://tex.stackexchange.com/questions/123528/changing-font-size-in-an-example
\expandafter\def\expandafter\resumo\expandafter{\resumo\setlength{\parindent}{0pt}\let\par\relax}

\begin{document}

\begin{resumo}
    O texto do resumo deve ser digitado, em um único bloco,
    sem espaço de parágrafo. O resumo deve ser significativo,
    composto de uma sequência de frases concisas, afirmativas
    e não de uma enumeração de tópicos. Não deve conter
    citações.

    Deve usar o verbo na voz passiva. Abaixo do resumo,
    deve-se informar as palavras-chave (palavras ou
    expressões significativas retiradas do texto) ou, termos
    retirados de thesaurus da área.
\end{resumo}

\end{document}

I got a bunch of errors:

Redoing nameref's sectioning
Redoing nameref's label
LaTeX Info: Redefining \nameref on input line 7.
LaTeX Info: Redefining \ref on input line 7.
LaTeX Info: Redefining \pageref on input line 7.
LaTeX Info: Redefining \nameref on input line 7.
\myptabbox=\box47
\myptabboxwidth=\skip263

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.11     \end{resumo}

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.11     \end{resumo}

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

Well, despite the errors, the paragraphs are removed:

enter image description here


Related questions:

  1. Adding something automatically to every paragraph in an environment
  2. Best way to add hanging indent to (almost) every paragraph
  3. What does the \the\everypar do?
  4. How do I split a command into several lines and have LaTeX read it as only one line?
  5. Why does \everypar not work?
  6. Remove par indent from environment
  7. How to remove indentation for all paragraphs?
  8. Remove paragraph indent from abstract in article class
  9. Automatic noindent after quote environment
  • 1
    Do you really think that it is worth to invest time to get working code for this? Why don't you simply remove the empty lines and add the dashes manually where you want them? – Ulrike Fischer Aug 26 '17 at 18:11
  • Whether worth it I am not sure. This depends on how much difficult it would be to implement such, if it is possible. I think adding could be much difficult, so just disabling the automatic new paragraphs should be simple. I just do not why \let\par\relax do these errors. – user Aug 26 '17 at 18:27
  • Then add sensible semantic mark up. It would be easy to redefine, and certainly better than try to redefine \par to produce "sometimes a dash and sometimes not". – Ulrike Fischer Aug 26 '17 at 18:27
  • @UlrikeFischer, can we forget about the dash, and only fix the \let\par\relax errors? I am going to edit the question and ask only about it. – user Aug 26 '17 at 18:29
  • 1
    The command \resumo is defined to have an optional argument, so the \expandafter\def\expandafter\resumo\expandafter{\resumo...} will just do evil. – egreg Aug 26 '17 at 21:24
2

The environment resumo has an optional argument, so doing

\expandafter\def\expandafter\resumo\expandafter{\resumo\setlength{\parindent}{0pt}\let\par\relax}

is wrong to begin with.

Anyway, you need to end the paragraph somewhere, which can't be done because \par got redefined to do nothing.

In my opinion, you should avoid such tricks. But here's how you can do it properly.

\documentclass{abntex2}
\usepackage{xpatch}

\xapptocmd{\resumo}{\setlength{\parindent}{0pt}\let\par\relax}{}{}
\xpretocmd{\endresumo}{\endgraf}{}{}

\begin{document}

\begin{resumo}
    O texto do resumo deve ser digitado, em um único bloco,
    sem espaço de parágrafo. O resumo deve ser significativo,
    composto de uma sequência de frases concisas, afirmativas
    e não de uma enumeração de tópicos. Não deve conter
    citações.

    Deve usar o verbo na voz passiva. Abaixo do resumo,
    deve-se informar as palavras-chave (palavras ou
    expressões significativas retiradas do texto) ou, termos
    retirados de thesaurus da área.
\end{resumo}

\end{document}
  • Thanks for point out the fix! When I saw xpatch I thought about using etoolbox, but I found your answer on this other question explaining why use xpatch Please tutor the usage of patchcmd and xpatch – user Aug 26 '17 at 21:40
  • @user Yes, \patchcmd would not work. – egreg Aug 26 '17 at 21:42
4

The problem is that you have to restore \par before you can end the environment. Also, I don't trust your \expandafter redefinition, and I know \let will work.

\documentclass{abntex2}

\let\oldresumo=\resumo
\def\resumo{\oldresumo\bgroup
  \setlength{\parindent}{0pt}%
  \let\par\relax}

\let\oldendresumo=\endresumo
\def\endresumo{\egroup\oldendresumo}

\begin{document}

\begin{resumo}
    O texto do resumo deve ser digitado, em um único bloco,
    sem espaço de parágrafo. O resumo deve ser significativo,
    composto de uma sequência de frases concisas, afirmativas
    e não de uma enumeração de tópicos. Não deve conter
    citações.

    Deve usar o verbo na voz passiva. Abaixo do resumo,
    deve-se informar as palavras-chave (palavras ou
    expressões significativas retiradas do texto) ou, termos
    retirados de thesaurus da área.
\end{resumo}

\end{document}
4
\documentclass{abntex2}
\let\parOrig\par
\renewcommand\resumo[1][\resumoname]{%
    \PRIVATEbookmarkthis{#1}
    \renewcommand{\abstractnamefont}{\chaptitlefont}
    \renewcommand{\abstractname}{\ABNTEXchapterupperifneeded{#1}}
    \abstract\let\par\relax}
\renewcommand\endresumo{\let\par\parOrig
    \endabstract\PRIVATEclearpageifneeded}

\begin{document}

    \begin{resumo}
        O texto do resumo deve ser digitado, em um único bloco,
        sem espaço de parágrafo. O resumo deve ser significativo,
        composto de uma sequência de frases concisas, afirmativas
        e não de uma enumeração de tópicos. Não deve conter
        citações.

        Deve usar o verbo na voz passiva. Abaixo do resumo,
        deve-se informar as palavras-chave (palavras ou
        expressões significativas retiradas do texto) ou, termos
        retirados de thesaurus da área.
    \end{resumo}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.