[NTG-context] ConTeXt's equivalent of raisebox

2021-10-10 Thread noib3 via ntg-context
How can I make vertical microadjustments to individual characters in
ConTeXt?

In LaTeX I would do it with

```
\documentclass{article}
\begin{document}
\raisebox{-1pt}{f}oo
\end{document}
```

however the following doesn't work

```
\starttext
\raisebox{-1pt}{f}oo
\stoptext
```
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Default values for key-value macros

2021-10-10 Thread noib3 via ntg-context
The way I've been defining key-value macros is to first pass them to Lua,
handle the parsing there thanks to `utilities.parsers.settings_to_hash` and
then assign the resulting Lua table to ConTeXt variables.

This worked fine up to now, but I'm having problems with the following MWE:

```
\def\style#1[#2] {
  \ctxlua{userdata.style([==[#2]==])}
  \placestyle
}

\startluacode
  userdata = userdata or {}

  userdata.style = function(keyvals)
local style = {
  color = nil,
  text = nil,
}
args = utilities.parsers.settings_to_hash(keyvals)
for k, v in pairs(args) do
  style[k] = v
end
context.setvariables({'style'}, style)
  end
\stopluacode

\define\placestyle{
  \doiftext
{\getvariable{style}{text}}
{\color[\getvariable{style}{color}]{\getvariable{style}{text}}}
}

\starttext

\style[
  text={Some red text},
  color=red,
]

\style[
  color=blue,
]

\stoptext
```

Here I assign a default value of `nil` to every key, and then check if the
`text` variable is empty before printing it. I would expect the second
macro not to print anything since its `text` should be nil, instead both
macros print 'Some red text', the first one in red and the second one in
blue.

I have attached a screenshot of the output.

What am I doing wrong?
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Placing SVG icons and text side by side

2021-10-07 Thread noib3 via ntg-context
How can I place an SVG icon "inline", i.e. side by side to some text?
Here's my MWE

```
\useURL
  [github]
  [https://github.com/test]
  []
  [github.com/test]

\starttext
  \placefigure[none]{}{\externalfigure[github.svg][width=17.5pt]}
  \from[github]
\stoptext
```

I have attached a screenshot of the output and the SVG file.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] ConTeXt's equivalent of standalone class

2021-10-02 Thread noib3 via ntg-context
Coming from LaTeX, when I had some TikZ pictures I wanted to add in my
document I would usually keep them on a separate file, I would compile them
with the standalone class so that the resulting PDF's size would be limited
to exactly the dimensions of the figure. I would then import the compiled
PDF in my main document. All this to not slow down compilation times.

What's the ConTeXt equivalent of this workflow? How can I keep the PDF
dimensions limited to the figure?
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Different footers for frontmatter and bodymatter

2021-08-18 Thread noib3 via ntg-context
I'd like to have two different footer setups: one for the frontmatter
(titlepage and table of contents) where the page number in roman numerals
is reported as a single centered footer. Another for the bodymatter where
the chapter is on the left footer and the pagenumber is on the right.

I can switch between roman numerals and numbers with

```
\defineconversionset
  [frontpart:pagenumber]
  []
  [romannumerals]

\defineconversionset
  [bodypart:pagenumber]
  []
  [numbers]
```

but I can't figure out how to have two different footer setups. Right now I
have

```
\setupfootertexts
  [chapter]
  [pagenumber]
```
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Using Lua to format lecture titles

2021-08-17 Thread noib3 via ntg-context
I'm trying to create a new lecture environment starting from the base
section.

I'd like its title to be `Lecture : ` if a title is
provided, and `Lecture ` if it isn't. This title should also be
reported in the left footer and in the table of contents.

This is the code I have so far:

```
\definehead
  [lecture]
  [section]

\setuphead
  [lecture]
  [
command=\Lecture,
style=\bfc,
  ]

\setuplabeltext
  [lecture={Lecture}]

\define[2]\Lecture{\ctxlua{
  userdata.format_lecture_title({
label = context.labeltext('lecture'),
number = [==[#1]==],
title = [==[#2]==],
  })
}}

\setupfootertexts
  [\ctxlua{
userdata.format_lecture_title({
  label = context.labeltext('lecture'),
  number = context.getmarking({'lecturenumber'}),
  title = context.getmarking({'lecture'}),
})
  }]
  [pagenumber]

\startluacode
  userdata = userdata or {}

  function userdata.format_lecture_title(args)
if args.title and args.title ~= '' then
  context('%s %s: %s', args.label, args.number, args.title)
else
  context('%s %s', args.label, args.number)
end
  end
\stopluacode

\setupcombinedlist
  [content]
  [list={lecture}]

\setuplist
  [lecture]
  [
alternative=c,
command=\Lecture, % this seems to have no effect?
  ]

\starttext

\completecontent

% Both title and left footer should be 'Lecture 1: Foo'
\startlecture [title={Foo}]
Foo bar baz
\stoplecture

\page

% Both title and left footer should be 'Lecture 2'
\startlecture []
Foo bar baz
\stoplecture

\stoptext
```

Unfortunately none of them are reported correctly. The title in the body is
formatted simply as `Lecture`, the one in the left footer is formatted as
`Lecture`, and the one in the table of contents isn't
affected at all.

What am I doing wrong?
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___