ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] A few question about defining symbols and creating downarrow to illustrate function rules
@ 2024-11-24 18:08 Jethro Djan
  2024-11-24 20:06 ` [NTG-context] " Henning Hraban Ramm
  0 siblings, 1 reply; 5+ messages in thread
From: Jethro Djan @ 2024-11-24 18:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1917 bytes --]

Hello,

I have a few questions.

1. What is the best way to get a symbol from a font you are not using as
your main?

%% start MWE

\starttext

\definesymbol[cedis][\utfchar{“20B5}]
\def\cedis{
  \switchtobodyfont[dejavu]\tf\symbol[cedis]
}

I have GH\cedis 10.00 in my pocket


\stoptext

%% end MWE

I tried to use \getglyph because I saw it being used in a similar way (but
not with unicode characters) like this:
\definesymbol[cedis][\getglyph{dejavu}{\utfchar{"20B5}}]

It didn't work.

2. I would like a more robust method to create a diagram (ie., a series of
input and outputs where you are then required to tell the rule of the
mapping). The inputs will be up with the outputs below and a downward
pointing arrow between them.

%% start MWE

\starttext

\define[2]\xdownarrow{
\startframed[frame=off,offset=0pt,width=0.8cm]
\startMPcode
numeric u, w; u := .3cm; w := 2pt;
pair pointX, pointY; path pointXY;
pointX := origin; pointY := pointX shifted (0,-3u);
draw pointX -- pointY withpen pencircle scaled .6w;
drawarrow pointX -- pointY withpen pencircle scaled .6w;
labeloffset := u;
label.top (textext("\dm{#1}"), pointX);
label.bot (textext("\dm{ #2 }"), pointY);
\stopMPcode
\stopframed
}

\startitemize[n]

\item Find the rule of the mapping:
\startplacefigure[location=none]
\startframed[frame=off,offset=0pt,]
\xdownarrow{x}{y}
\hspace[big]
\xdownarrow{1}{3}
\hspace[big]
\xdownarrow{2}{1}
\hspace[big]
\xdownarrow{3}{-1}
\hspace[big]
\xdownarrow{4}{-3}
\hspace[big]
\xdownarrow{5}{-5}
\stopframed
\stopplacefigure

\startitemize[a]

\item \im{y = 2x + 2}
\item \im{y = -2x + 2}
\item \im{y = 4x}
\item \im{y = -2x + 5}

\stopitemize
\stopitemize

%% stop MWR

How can I achieve this more elegantly with better spacing and the arrow
pointing to the number instead (-) for negative numbers?


Regards,
Jethro

[-- Attachment #1.2: Type: text/html, Size: 3164 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: A few question about defining symbols and creating downarrow to illustrate function rules
  2024-11-24 18:08 [NTG-context] A few question about defining symbols and creating downarrow to illustrate function rules Jethro Djan
@ 2024-11-24 20:06 ` Henning Hraban Ramm
  2024-11-24 21:52   ` [NTG-context] " Alan Braslau via ntg-context
  0 siblings, 1 reply; 5+ messages in thread
From: Henning Hraban Ramm @ 2024-11-24 20:06 UTC (permalink / raw)
  To: ntg-context

Am 24.11.24 um 19:08 schrieb Jethro Djan:
> Hello,
> 
> I have a few questions.
> 
> 1. What is the best way to get a symbol from a font you are not using as 
> your main?

e.g.
\definefontsynonym [MySymFont] [file:MySymFont.ttf]
\definesymbol[cedis][\getglyphstyled{MySymFont}{\tochar{x:20B5}}]
\def\cedis{\symbol[cedis]}

or just

\def\cedis{{\definedfont[MySymFont*default]\tochar{x:20B5}}}

> \definesymbol[cedis][\utfchar{“20B5}]
> \def\cedis{
>    \switchtobodyfont[dejavu]\tf\symbol[cedis]
> }
> 
> I have GH\cedis 10.00 in my pocket

Don’t use \switchtobodyfont for a single character.
For such cases, a fallback font is probably better.

\definefontfallback
	[symbolfallback]
	[name:MySymFont]
	[0x20B5]% can also be a list or range
	[check=yes,force=no]
\definetypeface [MyMainFamily]
	[rm] [serif] [palatino]
	[default][fallbacks=symbolfallback]

https://wiki.contextgarden.net/Command/definefontfallback

> 2. I would like a more robust method to create a diagram (ie., a series 
> of input and outputs where you are then required to tell the rule of the 
> mapping). The inputs will be up with the outputs below and a downward 
> pointing arrow between them.

Sorry, can’t help you here.
Better don’t mix different subjects in one message.

Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: creating downarrow to illustrate function rules
  2024-11-24 20:06 ` [NTG-context] " Henning Hraban Ramm
@ 2024-11-24 21:52   ` Alan Braslau via ntg-context
  2024-11-25  6:01     ` Jethro Djan
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Braslau via ntg-context @ 2024-11-24 21:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Alan Braslau

On Sun, 24 Nov 2024 21:06:23 +0100
Henning Hraban Ramm <texml@fiee.net> wrote:

> > 2. I would like a more robust method to create a diagram (ie., a
> > series of input and outputs where you are then required to tell the
> > rule of the mapping). The inputs will be up with the outputs below
> > and a downward pointing arrow between them.  
> 
> Sorry, can’t help you here.
> Better don’t mix different subjects in one message.

Yes, easier on everyone to keep issues separate.

You may want to look into either the flowchart module:
tex/texmf-context/doc/context/documents/general/manuals/charts-mkiv.pdf
or the nodes module:
tex/texmf-context/doc/context/documents/general/manuals/nodes.pdf

Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: creating downarrow to illustrate function rules
  2024-11-24 21:52   ` [NTG-context] " Alan Braslau via ntg-context
@ 2024-11-25  6:01     ` Jethro Djan
  2024-11-25  8:40       ` Henning Hraban Ramm
  0 siblings, 1 reply; 5+ messages in thread
From: Jethro Djan @ 2024-11-25  6:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1580 bytes --]

Didn’t know some of these stuff existed.

The caution to separate issues when asking questions is also heard.

Many thanks to Hraban and Alan for your solutions.

Jethro

On Sun, 24 Nov 2024 at 9:52 PM, Alan Braslau via ntg-context <
ntg-context@ntg.nl> wrote:

> On Sun, 24 Nov 2024 21:06:23 +0100
> Henning Hraban Ramm <texml@fiee.net> wrote:
>
> > > 2. I would like a more robust method to create a diagram (ie., a
> > > series of input and outputs where you are then required to tell the
> > > rule of the mapping). The inputs will be up with the outputs below
> > > and a downward pointing arrow between them.
> >
> > Sorry, can’t help you here.
> > Better don’t mix different subjects in one message.
>
> Yes, easier on everyone to keep issues separate.
>
> You may want to look into either the flowchart module:
> tex/texmf-context/doc/context/documents/general/manuals/charts-mkiv.pdf
> or the nodes module:
> tex/texmf-context/doc/context/documents/general/manuals/nodes.pdf
>
> Alan
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki     : https://wiki.contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 2602 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: creating downarrow to illustrate function rules
  2024-11-25  6:01     ` Jethro Djan
@ 2024-11-25  8:40       ` Henning Hraban Ramm
  0 siblings, 0 replies; 5+ messages in thread
From: Henning Hraban Ramm @ 2024-11-25  8:40 UTC (permalink / raw)
  To: ntg-context

Am 25.11.24 um 07:01 schrieb Jethro Djan:
> Didn’t know some of these stuff existed.

That happens even to old hands. Hans himself sometimes forgets what’s in 
ConTeXt ;)

> Many thanks to Hraban and Alan for your solutions.

You’re welcome.

Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-25  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-24 18:08 [NTG-context] A few question about defining symbols and creating downarrow to illustrate function rules Jethro Djan
2024-11-24 20:06 ` [NTG-context] " Henning Hraban Ramm
2024-11-24 21:52   ` [NTG-context] " Alan Braslau via ntg-context
2024-11-25  6:01     ` Jethro Djan
2024-11-25  8:40       ` Henning Hraban Ramm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).