2

I use this command to type less: \begin{parse lines}[\noindent]{#1\\}. Its effect is to preserve linebreaks. Default LaTeX behavior is that single linebreaks are collapsed to nothing, and two-or-more linebreaks become a single linebreak. parse lines overrides that, so that each linebreak in the source creates an extra linebreak in the output.

But that means I can't use things like \raggedright, \theorem, and \begin{align}; LaTeX errors when they are combined with parse lines. Why is that? Is there an alternative to parse lines that respects multi-linebreaks and keeps word wrap, but allows me to use those commands?

8
  • 2
    Welcome to TeX.SX! What's parse lines?
    – egreg
    May 25, 2017 at 22:19
  • @egreg, its behavior can be seen at tex.stackexchange.com/a/153595/134587. It comes from the package parselines. May 25, 2017 at 22:22
  • 1
    Well, I'd never use such a package. What's your aim?
    – egreg
    May 25, 2017 at 22:29
  • I want to use it with the usual mathematics commands. But my overall goal is that I like having newlines and double newlines without needing to type \\ or double linebreaks; this makes my source file easier to handle for me, including easier transfers to other text applications which are mostly WYSIWYG. May 25, 2017 at 22:38
  • 1
    It's very unclear, sorry; usage of \\ should be very limited outside alignments such as tabular, matrix and the like.
    – egreg
    May 25, 2017 at 22:42

1 Answer 1

1

Reading the comments between the OP and others, it seems that what the OP desires might be provided with \obeylines. Perhaps this, therefore...

It allows \raggedright and by scoping the extent of the \obeylines, math environments like align can be employed.

I have encapsulated it in an environment obey, which takes as an optional argument the number of lines to back-skip upon exit, which may be needed when transitioning to displaystyle math environments.

Here is the MWE

\documentclass{article}
\usepackage{amsmath}
\newenvironment{obey}[1][0]{\obeylines\xdef\bsmult{#1}}{\par\vspace{-\bsmult\baselineskip}}
\edef\svparindent{\the\parindent}
\begin{document}
\begin{obey}[1]
JUSTIFIED: And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. 
this 
is a
test.
 And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. 
\end{obey}
\begin{align}
 y &= mx + b\\
 e &= mc^2
\end{align}
\begin{obey}
RAGGED:this continues the test.
\raggedright\parindent\svparindent\relax
And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. And here, is more. 
\end{obey}
This is the next text outside of \texttt{obey} mode.
\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.