[NTG-context] How do I get an empty line in a \framed[align=flushleft]{} item?
Gerben Wierda
gerben.wierda at rna.nl
Fri May 1 01:44:37 CEST 2020
> On 30 Apr 2020, at 22:54, Wolfgang Schuster <wolfgang.schuster.lists at gmail.com> wrote:
>
> Gerben Wierda schrieb am 30.04.2020 um 22:47:
>> In normal TeX, when I type
>> Aap\\\\Aap
>> I get something like
>> Aap
>> Aap
>> But inside a \framed[align=]{} the empty line disappears. How do I get it back?
>> Minimal example:
>> \starttext
>> Testing\\\\Testing
>> \page
>> \framed[align=flushleft]{Testing\\\\Testing}
>> \stoptext
>
> Use \blank
Too happy too soon. And I recall I ran into this earlier a while ago in another setting ago. But I thought of a solution.
Background:
I am automatically converting input from an XML file to METAPOST/ConTeXt. The input may contain one or more newlines.The text must end up in \framed[align=??, width=??] to be typeset.
I use lua to convert and make it safe to pass to METAPOST as a string argument that METAPOST can pass on to textext(), using the following function:
function doubleQuotableEscapedConTeXtString( str)
local rep = lpeg.replacer {
{ '\n', '\\blank ' },
{ '{', '{\\textbraceleft}' },
{ '}', '{\\textbraceright}' },
{ '#', '{\\texthash}' },
{ '$', '{\\textdollar}' },
{ '&', '{\\textampersand}' },
{ '%', '{\\textpercent}' },
{ '\\','{\\textbackslash}' },
{ '|', '{\\textbar}' },
{ '_', '{\\textunderscore}' },
{ '~', '{\\textasciitilde}' },
{ '^', '{\\textasciicircum}' },
{ '"', "\"&ditto&\"" },
}
return rep:match(str)
end
Where it now says \\blank, it used to say \\\\.
Problem
\\\\ gets me what I want if there is one \n (it turns into one new line), but with two \n in succession it still gets me only a single ’newline'
\\blank gets me what I want if there are multiple newlines, but gets me an extra empty line when I only want ’next line’ and multiple \blanks do not work
But I found the solution by using \strut\\ instead of \blank. In the above table:
{ ‘\n', ‘\\strut\\\\' },
This fools ConTeXt in thinking there actually is something on that line and so multiple \\ will work.
G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20200501/cfabee17/attachment-0001.htm>
More information about the ntg-context
mailing list