5

In Latex, the following MWE:

\documentclass{article}

\begin{document}
Hello World\linebreak
Hello World\linebreak
Hello World\linebreak
Hello World
\end{document}

leaves each line fully justified (to horrible effect).

But In ConTeXt, neither \crlf, nor \\, nor any of the documented line delimiters seem to have this behaviour:

\starttext
Hello world \crlf
Hello world \\
Hello world | |
Hello world
\stoptext

I've scoured the wiki and looked through the reference manual for a solution, unsuccesfully.

6
  • Did you try \break? Hello world\break seems to do.
    – egreg
    Jul 17 '15 at 22:03
  • 1
    Thanks, you're right. Not one mention of it in a 350+ pg reference manual, nor the wiki. Goodbye, ConTeXt. Jul 17 '15 at 22:10
  • 1
    @JaredKulik: \break is defined in plain TeX. Like LaTeX, ConTeXt also includes many macros that are defined in plain TeX without documenting them.
    – Aditya
    Jul 19 '15 at 1:47
  • BTW, why do you want to do this? See the XY problem. There may be more canonical way to achieve the desired effect in ConTeXt.
    – Aditya
    Jul 19 '15 at 1:51
  • 1
    @Aditya, Duly noted. LaTeX does offer and document its own way of doing it even if TeX can be used, ConTeXt doesn't and I was left scratching my head. Not worth arguing over. Jul 19 '15 at 12:33
3

As @egreg noted, \break does the job.

3
  • 1
    Note that \break is essentially \penalty-10000, so it will also cause a page break if issued between paragraphs.
    – egreg
    Jul 18 '15 at 5:38
  • @egreg: IIUC, \linebreak is essentially \penalty-1000 followed by \hskip \lastskip if \lastskip > 0pt. In the LaTeX example included in the MWE above, wont \linebreak also expand to penalty -1000?
    – Aditya
    Jul 19 '15 at 1:50
  • @Aditya but this isn't about linebreak, it's about a break that does not break a page with the startlinealignment environment. Of course there is pagebreak, but that's not the point. And one also has \hbox to \hsize bla bla \break, but that's not the point either. Also, I'm getting a Lua linebreak filter failed reverting to default ad infinitum here. Any insights about it, your majesty? :)
    – doed
    Jul 19 '15 at 12:57
1

To justify a single line of text you use \maxaligned or \startmaxaligned. For the same effect for the last line in a paragraph you can use the paragraph keyword for the \startalignment environment.

\starttext

\startlinealignment[max]
Hello world
\stoplinealignment

% \startmaxaligned
% Hello world
% \stopmaxaligned
%
% \maxaligned{Hello world}

\startalignment[paragraph]
\input ward
\stopalignment

\stoptext

Example for justified text.

1
  • I don't think this answers the question.
    – egreg
    Jul 18 '15 at 5:36

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.