2

I have the following macro

\mainlanguage [de] \definepapersize[MyBook][A5] \setuppapersize[MyBook][A5] \definestartstop[Test][commands=\setups{Test}] \def\Test{\doTest} \def\Test[#1]{ \placeongrid[top]{ {\startalignment [flushleft] #1 \stopalignment \startalignment [flushright] (\bf Test Message) \stopalignment} \blank[big] } } \starttext \Test[Wrong] \Test[This one is correct, correct, correct, correct, correct.] This one is wrong, wrong, wrong, wrong, wrong. \startalignment [flushright] (\bf Test Message) \stopalignment \stoptext 

with three examples. What I want is this:

\Test[#1] should produce #1 and #2 with the following properties:

  • #1 should be flushleft, #2 flushright
  • #2 should never be breaked into two lines
  • if they fit into one line, then they should do that, not like the above first example

How to do that?

4
  • What if #1 or #2 is larger than a line? What if #1 + #2 is larger than a line. If you ignore these cases then \hbox to \textwidth{#1 \hfill #2} should work. Commented Nov 1, 2012 at 16:28
  • The only precondition is: #2 is smaller than a line. But #1 may be much larger, in any cases #1 should be flushleft and #2 should be flushright. And #2 should be in the last line of #1, if there is space for it. If not, then #2 has to be in the next line. Commented Nov 2, 2012 at 11:47
  • 2
    Are you trying to write attribution for quotes? Simply using \wordright{#2} should be sufficient. Commented Nov 2, 2012 at 12:25
  • Indeed, that is it! Commented Nov 2, 2012 at 14:43

1 Answer 1

1

I am using the annotation module for a better key-value driven syntax (although you can also use \definestartstop). You can use \wordright{...} to place a word on the right. For example:

\usemodule[annotation] \defineannotation [Quote] [ alternative=command, spacebefore=big, spaceafter=big, command=\PlaceQuote, ] \define[2]\PlaceQuote {\startalignment[flushleft] \placeannotationcontent \stopalignment \blank[samepage] \wordright{\placeannotationtitle}} \setuppapersize[A5] \starttext \input ward \startQuote[title={Donald Knuth}] \input knuth \stopQuote \input ward \stoptext 

gives

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.