1

Is it possible to have right-justified left-to-right text so that the text in two-column layouts are mirror images of each other, vertically? Given the second example in the question ConTeXt: uniform handling of whitespace in margin and text, changing the alignment of the left column to align={flushright,broad} creates a non-justified ragged-left edge causing it to become longer than the right column.

Here is my MWE. The first page is the intended input, the last the intended output. Everything in between are my progressive attempts. Regarding the last page, even though it is mostly set (read the comments) as intended no sane person should have to go through that process.

\setuppapersize[letter]

\setuplayout
    [backspace=0.5in,
     width=7.5in,
     %
     topspace=0.25in,
     height=10.5in,
     header=0.25in,
     headerdistance=0.25in,
     footer=0.25in,
     footerdistance=0.25in,
    ]

\setupwhitespace[medium]

\define[1]\heading{%
    \blank[big,samepage]%
    \dontleavehmode{\bfc\setupinterlinespace\strut#1}%
    \blank[medium,samepage]%
}

% Only used to generate the final effect.
\define[1]\rightheading{%
    \blank[big,samepage]%
    \dontleavehmode{\bfc\setupinterlinespace\strut\rightaligned{#1}}%
    \blank[medium,samepage]%
}

\definecolumnset[TwoColumns][n=2]

\defineparagraphs[MirrorTwo][n=2]
\setupparagraphs[MirrorTwo][1][align=flushright]

\defineparagraphs[MirrorTwoB][n=2]

\showframe


\starttext
    % This is the working text.
    \startcolumnset[TwoColumns]

        \heading{Left 1}
        \samplefile{ward}

        \heading{Left 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Left 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}

    \column

        \heading{Right 1}
        \samplefile{ward}

        \heading{Right 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}

    \stopcolumnset


    \page


    % Here is an attempt using columnsets. Strangely enough, text overflowing
    % from the right column into the left column actually introduces vertical
    % whitespace at the top of the left column as if the entire left column
    % were being pushed down. So comment out the overflowing text caused by an
    % incorrect alignment of the left column.
    \startcolumnset[TwoColumns]

        \startalignment[flushright]
        \heading{Left 1}
        \samplefile{ward}

        \heading{Left 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Left 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        %\samplefile{jojomayer}
        \stopalignment

    \column

        \startalignment[normal]
        \heading{Right 1}
        \samplefile{ward}

        \heading{Right 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        %\samplefile{jojomayer}
        \stopalignment

    \stopcolumnset


    \page


    % Here is an attempt using columns. None of the options controlling
    % vertical whitespace work and columns produce more vertical whitespace
    % than columnsets. So right off we have to comment out initially
    % overflowing text. Then as with columnsets, the incorrect alignment of the
    % left column requires commenting out the additional overflowing text.
    \startcolumns[n=2,blank=small,height=0pt,]

        \startalignment[flushright]
        \heading{Left 1}
        \samplefile{ward}

        \heading{Left 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Left 3}
        \startitemize
        \item 1
        \item 2
        %\item 3
        \stopitemize
        %\samplefile{jojomayer}
        \stopalignment

    \column

        \heading{Right 1}
        \samplefile{ward}

        \heading{Right 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        %\item 3
        \stopitemize
        %\samplefile{jojomayer}

    \stopcolumns


    \page


    % Here is an attempt using columned paragraphs. This is actually the second
    % attempt, with nested paragraphs. The alignment of the left column is
    % still incorrect. What's new is that the nested paragraphs have no
    % separation - no vertical whitespaces - as configured by
    % '\setupwhitespace'.
    \startMirrorTwo

        \heading{Left 1}
        \samplefile{ward}

        \heading{Left 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Left 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}

    \MirrorTwo

        \heading{Right 1}
        \samplefile{ward}

        \heading{Right 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}

    \stopMirrorTwo


    \page


    % This was actually the first attempt using columned paragraphs. The
    % headings have to be inside the paragraphs for the column splits. Overall
    % this is a bulkier approach than the one immediately above, and still
    % presents both issues: incorrect alignment of the left column, and missing
    % separation of the nested paragraphs (even with '\par' - though '\blank'
    % works). However the last issues applies only to paragraphs from
    % '\samplefile'. Local nested paragraphs can be flattened into new
    % outer-level paragraphs. What's interesting is that even though the
    % alignment of the left column breaks alignment between the left and right
    % columns, the paragraphs remain aligned.
    \startMirrorTwo
        \heading{Left 1}
        \samplefile{ward}
    \MirrorTwo
        \heading{Right 1}
        \samplefile{ward}
    \stopMirrorTwo

    \startMirrorTwo
        \heading{Left 2}
        \samplefile{knuth}
    \MirrorTwo
        \heading{Right 2}
        \samplefile{knuth}
    \stopMirrorTwo

    \startMirrorTwo
        \samplefile{weisman}
    \MirrorTwo
        \samplefile{weisman}
    \stopMirrorTwo

    \startMirrorTwo
        \heading{Left 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}
    \MirrorTwo
        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}
    \stopMirrorTwo


    \page


    % Right, so here is the intended effect, which we have to build from
    % scratch. Maybe this can be automated by a render setup if we can have
    % access to the last line, to apply '\rightaligned'? We can't use
    % paragraphs because I don't know how to setup the vertical whitespace of
    % nested paragraphs, especially with '\samplefile'. If we're stuck with
    % columns we should avoid simple columns '\start...stopcolumns' because
    % there is too much vertical whitespace.
    %
    % OK so this isn't perfect. The left-column headings have more vertical
    % whitespace, somehow due to '\rightaligned'. The manually hyphenated
    % dashes don't match. And the itemgroup hasn't been properly aligned.
    \startcolumnset[TwoColumns]

        \rightheading{Left 1}
        The Earth, as a habitat for animal life, is in old age and has a fatal
        illness.  Several, in fact. It would be happening whether humans had
        ever evolved or not.  But our presence is like the effect of an old-age
        patient who smokes many packs of cigarettes per
        \rightaligned{day—and we humans are the cigarettes.}

        \rightheading{Left 2}
        Thus, I came to the conclusion that the designer of a new system must
        not only be the implementer and first large||scale user; the designer
        should also
        \rightaligned{write the first user manual.}

        The separation of any of these four components would have hurt \TeX\
        significantly. If I had not participated fully in all these activities,
        literally hundreds of improvements would never have been made, because
        I would never have thought of them or per||
        \rightaligned{ceived why they were important.}

        But a system cannot be successful if it is too strongly influenced by a
        single person. Once the initial design is complete and fairly robust,
        the real test begins as people with many different viewpoints un||
        \rightaligned{dertake their own experiments.}

        Since the mid-1990s, humans have taken an unprecedented step in Earthly
        annals by introducing not just exotic flora or fauna from one ecosystem
        into another, but actually inserting exotic genes into the operating
        systems of individual plants and animals, where they're intended to do
        exactly the same
        \rightaligned{thing: copy themselves, over and over.}

        \rightheading{Left 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        %If we surrender the thing that separates us from machines, we will be replaced by
        %machines. The more advanced machines will be, the more human
        %\rightaligned{we will have to become.}

    \column

        \heading{Right 1}
        \samplefile{ward}

        \heading{Right 2}
        \samplefile{knuth}

        \samplefile{weisman}

        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        \item 3
        \stopitemize
        \samplefile{jojomayer}

    \stopcolumnset


    \page


    % Take two regarding intended effect, this time using paragraphs. Luckily
    % no manual hyphenation was required this time, so no need to research
    % which type of dash I'd need. The headings consume slightly more vertical
    % whitespace than in columnsets, but that's relatively easy to tweak in the
    % final output. For some strange reason, my custom paragraphs here are
    % separate by more vertical whitespace that the standard paragraphs in
    % columnsets. So, I'm still forced to comment out an '\item' entry here to
    % keep everything on the same page. Also the left column is not exactly
    % flushright - the hz adjustment should be applied to the left side, not
    % the right. Overall its a pretty good start.
    \startMirrorTwoB
        \rightheading{Left 1}
        The Earth, as a habitat for animal life, is in old age and has a fatal
        illness.  Several, in fact. It would be happening whether humans had
        ever evolved or not.  But our presence is like the effect of an old-age
        patient who smokes many packs of cigarettes per day
        \rightaligned{—and we humans are the cigarettes.}
    \MirrorTwo
        \heading{Right 1}
        \samplefile{ward}
    \stopMirrorTwoB

    \startMirrorTwoB
        \rightheading{Left 2}
        Thus, I came to the conclusion that the designer of a new system must
        not only be the implementer and first large||scale user; the designer
        should also write
        \rightaligned{the first user manual.}
    \MirrorTwo
        \heading{Right 2}
        Thus, I came to the conclusion that the designer of a new system must
        not only be the implementer and first large||scale user; the designer
        should also write the first user manual.
    \stopMirrorTwoB

    \startMirrorTwoB
        The separation of any of these four components would have hurt \TeX\
        significantly. If I had not participated fully in all these activities,
        literally hundreds of improvements would never have been made, because
        I would never have thought of them or perceived
        \rightaligned{why they were important.}
    \MirrorTwo
        The separation of any of these four components would have hurt \TeX\
        significantly. If I had not participated fully in all these activities,
        literally hundreds of improvements would never have been made, because
        I would never have thought of them or perceived why they were
        important.
    \stopMirrorTwoB

    \startMirrorTwoB
        But a system cannot be successful if it is too strongly influenced by a
        single person. Once the initial design is complete and fairly robust,
        the real test begins as people with many different viewpoints undertake
        \rightaligned{their own experiments.}
    \MirrorTwo
        But a system cannot be successful if it is too strongly influenced by a
        single person. Once the initial design is complete and fairly robust,
        the real test begins as people with many different viewpoints undertake
        their own experiments.
    \stopMirrorTwoB

    \startMirrorTwoB
        Since the mid-1990s, humans have taken an unprecedented step in Earthly
        annals by introducing not just exotic flora or fauna from one ecosystem
        into another, but actually inserting exotic genes into the operating
        systems of individual plants and animals, where they're intended to do
        exactly the same thing:
        \rightaligned{copy themselves, over and over.}
    \MirrorTwo
        Since the mid-1990s, humans have taken an unprecedented step in Earthly
        annals by introducing not just exotic flora or fauna from one ecosystem
        into another, but actually inserting exotic genes into the operating
        systems of individual plants and animals, where they're intended to do
        exactly the same thing: copy themselves, over and over.
    \stopMirrorTwoB

    \startMirrorTwo
        \rightheading{Left 3}
        \startitemize
        \item 1
        \item 2
        %\item 3
        \stopitemize
    \MirrorTwo
        \heading{Right 3}
        \startitemize
        \item 1
        \item 2
        %\item 3
        \stopitemize
    \stopMirrorTwo

    \startMirrorTwoB
        If we surrender the thing that separates us from machines, we will be
        replaced by machines. The more advanced machines will be, the more
        human we will
        \rightaligned{have to become.}
    \MirrorTwo
        If we surrender the thing that separates us from machines, we will be
        replaced by machines. The more advanced machines will be, the more
        human we will have to become.
    \stopMirrorTwoB


\stoptext

So basically I'm trying to create a right justified alignment that isn't limited to just paragraphs.

Here are the first and last pages:

input/output

And I guess an extra-extra-minimal non-working example would be:

\setuppapersize[A5]
\setupalign[normal]
\showframe
\starttext
    \samplefile{darwin}
\stoptext
  • 1
    I think it would be better practice to paste your MWE here. Moreover, your linked MWE has two pieces, one of them, IMHO not being too useful for this case. In this peculiar case, a picture might be helpful. – sztruks Dec 6 '18 at 6:59
  • Well, your MWE has to be changed to highlight your issue. Remember we should'nt have to change your MWE but use them out of the box and see the problem. Please clean up your MWE ripping off anything not connected to your issue, add the desired options and edit your post. Thanks. – sztruks Dec 6 '18 at 7:05
  • You're right, that was a terrible MWE. – user19087 Dec 6 '18 at 20:28
  • Can make it a bit shorter? It is not that simple to copy/paste… Thanks. – sztruks Dec 6 '18 at 21:34
  • Do you want to typeset bilingual columns? In that case Parallel text in ConTeXt might be interesting for you. Otherwise I don't see any reason to format text like this. It's just painfully hard to read. – Henri Menke Dec 7 '18 at 6:05
2

The alignment setting you are looking for is called end. You can also use \flushedrightlastline as a local switch (like \raggedright).

\setuppapersize[A5]
\setupalign[end]

\define[1]\heading{%
    \blank[big,samepage]%
    \dontleavehmode{\bfc\setupinterlinespace\strut#1}%
    \blank[medium,samepage]%
}

\showframe
\starttext

\heading{Left 1}
\samplefile{ward}

\heading{Left 2}
\samplefile{knuth}

\samplefile{weisman}

\heading{Left 3}
\startitemize
\item 1
\item 2
\item 3
\stopitemize
\samplefile{jojomayer}

\stoptext

Unfortunately there seem to be some issues with this setting (red ellipses in the screenshot). There does not really seem to be a pattern as to when it fails. But because you want to use it, it is your responsibility to ask on the mailing list and convince Hans to fix it. The implementation is in typo-lin.lua.

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.