[NTG-context] numerator is too high in \frac{3}{4}, in palatino

2014-05-01 Thread Sanjoy Mahajan
I've noticed the following issue with how high the numerator is placed,
but only when using Palatino:

\setupbodyfont[palatino]
\starttext
\startformula
{3\over4}\quad {1\over2}
\stopformula
\stoptext

The 3 and the 1 sit quite high above the division line, esp. in
comparison with the gap below the line (above the 4 and the 2).

The place okay without the \setupbodyfont[palatino], so maybe it is
something incorrect in the font parameters?

The fonts are (from 'pdffonts'):

EUEJAR+TeXGyrePagella-RegularCID Type 0C   Identity-H   yes yes 
yes 18  0
UPBTGS+TeXGyrePagellaMath-RegularCID Type 0C   Identity-H   yes yes 
yes 19  0

And it is compiled with 2014.03.27 20:04 MKIV.

Is there a way to adjust the spacing, or an alternative workaround?

-Sanjoy
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] too many open files?

2014-05-01 Thread Andrea Valle
Thanks a lot!
-a-

--
Andrea Valle
--
CIRMA - StudiUm
Università degli Studi di Torino
--> http://www.cirma.unito.it/andrea/
--> http://www.fonurgia.unito.it/andrea/
--> http://www.flickr.com/photos/vanderaalle/sets/
--> http://vimeo.com/vanderaalle
--> andrea.va...@unito.it
--

"This is a very complicated case, Maude. You know, a lotta ins, a lotta outs, a 
lotta what-have-yous." 
(Jeffrey 'The Dude' Lebowski)

On 01 May 2014, at 11:27, Henning Hraban Ramm  wrote:

> 
> Am 2014-05-01 um 05:13 schrieb Andrea Valle :
> 
>> Dear,
>> 
>> I’m compiling the new version of my manual on the SuperCollider language, 
>> using a project structure, and I’m including a lot of pdfs, as I’m 
>> automatically generating figures containing colorised code that have to 
>> included  in the book. Btw I’m quite happy of the results! Thanks to devs 
>> for your work.
>> 
>> Anyway, I’m stuck at this. I’m getting this error, seems related to the 
>> number of included pdfs
>> 
>> > file '/paperiProgetti/SC/introSC/code/controlli/map.pdf': Too many open 
>> files.
>> 
>> !LuaTeX error: xpdf: reading PDF image failed
>> ==> Fatal error occurred, no output PDF file produced!
>> 
>> What can I do?
> 
> See http://wiki.contextgarden.net/LilyPond#Too_many_open_files :
> 
> *Too many open files*
> 
> With bigger projects ... you might run into "too many open files" errors, at 
> least in Linux, OSX and other Unix-like OSes. 
> Ask your shell about the open files maximum and set it higher:
> 
> $ ulimit -n
> 256
> ulimit -S -n 2048
> 
> 
> 
> Greetlings, Hraban
> ---
> http://www.fiee.net/texnique/
> http://wiki.contextgarden.net
> https://www.cacert.org (I'm an assurer)
> 
> ___
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___
> 

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] Empty heads after leading whitespace

2014-05-01 Thread Maggyero
> before=\empty,

\empty is not even required. The problem with your solution (setting
'before=' i.e. empty) is that there is also no whitespace before a
subsection which doesn't start on a new page.

Any better ideas?
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Wolfgang Schuster

Am 01.05.2014 um 20:00 schrieb Aditya Mahajan :

> On Thu, 1 May 2014, Mikael P. Sundqvist wrote:
>> \startluacode
>> userdata = userdata or {}
>> function userdata.lundklippfyllbild(str, bredd, hojd)
>> if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
>> local skalning =
>> -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
>> context("\\vskip%ssp", skalning)
>> context.externalfigure({str},{width=bredd})
>> context.sprint("foo")
>> else
>> local skalning =
>> -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
>> context("\\hskip%ssp", skalning)
>> context.externalfigure({str},{height=hojd})
>> context.sprint("bar")
>> end
>> end
>> \stopluacode
>> 
>> \unexpanded\def\lundklippfyllbild#1#2#3{%
>> \startexternalfigurecollection[#1]%
>> \useexternalfigure[#1][#1]%
>> \stopexternalfigurecollection%
>> \clip[
>> width=#2,
>> height=#3,
>> hoffset=0mm,
>> voffset=0mm,
>> ]{%
>> \framed[width=#2,height=#3,align={middle,lohi},offset=overlay,frame=off]{%
>> \dimen0=\externalfigurecollectionminwidth{#1}%
>> \dimen2=\externalfigurecollectionmaxheight{#1}%
>> \dimen4=#2%
>> \dimen6=#3%
>> {\ctxlua{userdata.lundklippfyllbild([==[#1]==],[==[#2]==],[==[#3]==])}
>> 
>> 
>> 
>> and then run
>> 
>> 
>> \lundklippfyllbild{k.jpg}{\textwidth}{\textheight}
> 
> Here is an eTeX solution.
> 
> \unprotect
> 
> \newdimen\d_scaleandclip_actual_wd
> \newdimen\d_scaleandclip_actual_ht
> 
> \newdimen\d_scaleandclip_requested_wd
> \newdimen\d_scaleandclip_requested_ht
> 
> \newbox\scaleandclip_box
> 
> \installnamespace{scaleandclip}
> \installcommandhandler \scaleandclip {scaleandclip} \scaleandclip
> 
> \setupscaleandclip
>  [width=\textwidth,
>   height=\textheight]
> 
> \unexpanded\def\scaleandclip{\dodoubleempty\doscaleandclip}
> 
> \def\doscaleandclip[#1][#2]%
>  {\bgroup
>   \ifsecondargument
>  \edef\currentscaleandclip{#1}%
>  \setupcurrentscaleandclip[#2]%
>   \else\iffirstargument
>  \doifassignmentelse{#1}
>  {\let\currentscaleandclip\empty
>   \setupcurrentscaleandclip[#1]}
>  {\edef\currentscaleandclip{#1}}
>\else
>  \let\currentscaleandclip\empty
>\fi\fi
>\dowithnextboxcs\scaleandclip_finish\hbox}
> 
> \def\scaleandclip_finish
>{%
>  \d_scaleandclip_requested_wd \dimexpr\scaleandclipparameter\c!width\relax
>  \d_scaleandclip_requested_ht 
> \dimexpr\scaleandclipparameter\c!height\relax
>  %
>  \d_scaleandclip_actual_wd\wd\nextbox
>  \d_scaleandclip_actual_ht\dimexpr\ht\nextbox + \dp\nextbox\relax
>  %
>  \ifdim\dimexpr\d_scaleandclip_actual_wd*100/\d_scaleandclip_requested_wd 
> <
>\dimexpr\d_scaleandclip_actual_ht*100/\d_scaleandclip_requested_ht 
> \relax
>\setbox\scaleandclip_box\hbox
>{\scale[\c!width=\d_scaleandclip_requested_wd]{\box\nextbox}}%
>\scratchdimen=\the\dimexpr(\ht\scaleandclip_box - 
> \d_scaleandclip_requested_ht)/2\relax
>\clip
>  [
>\c!voffset=\scratchdimen,
>\c!height=\d_scaleandclip_requested_ht,
>  ]{\box\scaleandclip_box}%
>  \else
>\setbox\scaleandclip_box\hbox
>{\scale[\c!height=\d_scaleandclip_requested_ht]{\box\nextbox}}%
>\scratchdimen=\the\dimexpr(\wd\scaleandclip_box - 
> \d_scaleandclip_requested_wd)/2\relax
>\clip
>  [
>\c!hoffset=\scratchdimen,
>\c!width=\d_scaleandclip_requested_wd,
>  ]{\box\scaleandclip_box}%
>  \fi
>  \egroup}
> 
> \protect
> 
> The usage is:
> 
> \scaleandclip[width=..., height=...]{ ... any box ...}
> 
> simimlar to the usage of \scale macro.

We should convince Hans to add this functionality to the \scale macro with 
“factor=clip”.

Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Mikael P. Sundqvist
On Thu, May 1, 2014 at 8:00 PM, Aditya Mahajan  wrote:
> On Thu, 1 May 2014, Mikael P. Sundqvist wrote:
>>
>> \startluacode
>> userdata = userdata or {}
>> function userdata.lundklippfyllbild(str, bredd, hojd)
>> if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
>>  local skalning =
>> -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
>>  context("\\vskip%ssp", skalning)
>>  context.externalfigure({str},{width=bredd})
>>  context.sprint("foo")
>> else
>>  local skalning =
>> -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
>>  context("\\hskip%ssp", skalning)
>>  context.externalfigure({str},{height=hojd})
>>  context.sprint("bar")
>> end
>> end
>> \stopluacode
>>
>> \unexpanded\def\lundklippfyllbild#1#2#3{%
>> \startexternalfigurecollection[#1]%
>> \useexternalfigure[#1][#1]%
>> \stopexternalfigurecollection%
>> \clip[
>> width=#2,
>> height=#3,
>> hoffset=0mm,
>> voffset=0mm,
>> ]{%
>> \framed[width=#2,height=#3,align={middle,lohi},offset=overlay,frame=off]{%
>> \dimen0=\externalfigurecollectionminwidth{#1}%
>> \dimen2=\externalfigurecollectionmaxheight{#1}%
>> \dimen4=#2%
>> \dimen6=#3%
>> {\ctxlua{userdata.lundklippfyllbild([==[#1]==],[==[#2]==],[==[#3]==])}
>>
>>
>>
>> and then run
>>
>>
>> \lundklippfyllbild{k.jpg}{\textwidth}{\textheight}
>
>
> Here is an eTeX solution.
>
> \unprotect
>
> \newdimen\d_scaleandclip_actual_wd
> \newdimen\d_scaleandclip_actual_ht
>
> \newdimen\d_scaleandclip_requested_wd
> \newdimen\d_scaleandclip_requested_ht
>
> \newbox\scaleandclip_box
>
> \installnamespace{scaleandclip}
> \installcommandhandler \scaleandclip {scaleandclip} \scaleandclip
>
> \setupscaleandclip
>   [width=\textwidth,
>height=\textheight]
>
> \unexpanded\def\scaleandclip{\dodoubleempty\doscaleandclip}
>
> \def\doscaleandclip[#1][#2]%
>   {\bgroup
>\ifsecondargument
>   \edef\currentscaleandclip{#1}%
>   \setupcurrentscaleandclip[#2]%
>\else\iffirstargument
>   \doifassignmentelse{#1}
>   {\let\currentscaleandclip\empty
>\setupcurrentscaleandclip[#1]}
>   {\edef\currentscaleandclip{#1}}
> \else
>   \let\currentscaleandclip\empty
> \fi\fi
> \dowithnextboxcs\scaleandclip_finish\hbox}
>
> \def\scaleandclip_finish
> {%
>   \d_scaleandclip_requested_wd
> \dimexpr\scaleandclipparameter\c!width\relax
>   \d_scaleandclip_requested_ht
> \dimexpr\scaleandclipparameter\c!height\relax
>   %
>   \d_scaleandclip_actual_wd\wd\nextbox
>   \d_scaleandclip_actual_ht\dimexpr\ht\nextbox + \dp\nextbox\relax
>   %
>
> \ifdim\dimexpr\d_scaleandclip_actual_wd*100/\d_scaleandclip_requested_wd <
>
> \dimexpr\d_scaleandclip_actual_ht*100/\d_scaleandclip_requested_ht \relax
> \setbox\scaleandclip_box\hbox
>
> {\scale[\c!width=\d_scaleandclip_requested_wd]{\box\nextbox}}%
> \scratchdimen=\the\dimexpr(\ht\scaleandclip_box -
> \d_scaleandclip_requested_ht)/2\relax
> \clip
>   [
> \c!voffset=\scratchdimen,
> \c!height=\d_scaleandclip_requested_ht,
>   ]{\box\scaleandclip_box}%
>   \else
> \setbox\scaleandclip_box\hbox
>
> {\scale[\c!height=\d_scaleandclip_requested_ht]{\box\nextbox}}%
> \scratchdimen=\the\dimexpr(\wd\scaleandclip_box -
> \d_scaleandclip_requested_wd)/2\relax
> \clip
>   [
> \c!hoffset=\scratchdimen,
> \c!width=\d_scaleandclip_requested_wd,
>   ]{\box\scaleandclip_box}%
>   \fi
>   \egroup}
>
> \protect
>
> The usage is:
>
> \scaleandclip[width=..., height=...]{ ... any box ...}
>
> simimlar to the usage of \scale macro.
>
>
> \starttext
>
> \dontleavehmode
> \scaleandclip[width=3cm,
> height=3cm]{\externalfigure[cow.pdf][width=3cm,frame=on]}
> \scale[maxwidth=3cm,
> maxheight=3cm]{\externalfigure[cow.pdf][width=3cm,frame=on]}
>
> \dontleavehmode
> \scaleandclip[width=3cm,
> height=3cm]{\externalfigure[cow.pdf][width=3cm,height=10cm,frame=on]}
> \scale[maxwidth=3cm,
> maxheight=3cm]{\externalfigure[cow.pdf][width=3cm,height=10cm,frame=on]}
>
> \dontleavehmode
> \scaleandclip[width=3cm,
> height=3cm]{\externalfigure[cow.pdf][width=10cm,height=3cm,frame=on]}
> \scale[maxwidth=3cm,
> maxheight=3cm]{\externalfigure[cow.pdf][width=10cm,height=3cm,frame=on]}
>
> \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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___


Thanks Aditya!

That is more general and looks more ConTeXt-ish to me with the
options. I s

Re: [NTG-context] automatically adding commands to some characters

2014-05-01 Thread Pablo Rodriguez
On 04/29/2014 12:10 AM, Rik Kabel wrote:
> On 2014-04-28 17:53, Pablo Rodriguez wrote:
>> [...]
>> Is there any command that allows the addition of arbitrary commands when
>> a character appears in text? I mean, a way that internally replaces
>> "Council Directive 93/98/EEC" with "Council Directive 93/\hskip0pt
>> 98/\hskip0pt EEC"
>>
> \setbreakpoints in
> MKIV should do it. Just add it to you pandoc context template.

Many thanks for your help, Rik.

It is exactly what I needed.


Pablo
-- 
http://www.ousia.tk
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Empty heads after leading whitespace

2014-05-01 Thread Thangalin
\setuphead[section][%
placehead=empty,
before=,
after=]
\setuphead[subsection][%
placehead=yes,
before=\empty,
after={\blank[line]}]
\setupheadertexts[section]

\starttext
\showframe
\section{My section}
\subsection{My subsection (whitespace before)} % Here is my problem.
\page
\subsection{My subsection (NO whitespace before)}
\stoptext

Is that what you mean?
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Aditya Mahajan

On Thu, 1 May 2014, Mikael P. Sundqvist wrote:

\startluacode
userdata = userdata or {}
function userdata.lundklippfyllbild(str, bredd, hojd)
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
 local skalning =
-0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
 context("\\vskip%ssp", skalning)
 context.externalfigure({str},{width=bredd})
 context.sprint("foo")
else
 local skalning =
-0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
 context("\\hskip%ssp", skalning)
 context.externalfigure({str},{height=hojd})
 context.sprint("bar")
end
end
\stopluacode

\unexpanded\def\lundklippfyllbild#1#2#3{%
\startexternalfigurecollection[#1]%
\useexternalfigure[#1][#1]%
\stopexternalfigurecollection%
\clip[
width=#2,
height=#3,
hoffset=0mm,
voffset=0mm,
]{%
\framed[width=#2,height=#3,align={middle,lohi},offset=overlay,frame=off]{%
\dimen0=\externalfigurecollectionminwidth{#1}%
\dimen2=\externalfigurecollectionmaxheight{#1}%
\dimen4=#2%
\dimen6=#3%
{\ctxlua{userdata.lundklippfyllbild([==[#1]==],[==[#2]==],[==[#3]==])}



and then run


\lundklippfyllbild{k.jpg}{\textwidth}{\textheight}


Here is an eTeX solution.

\unprotect

\newdimen\d_scaleandclip_actual_wd
\newdimen\d_scaleandclip_actual_ht

\newdimen\d_scaleandclip_requested_wd
\newdimen\d_scaleandclip_requested_ht

\newbox\scaleandclip_box

\installnamespace{scaleandclip}
\installcommandhandler \scaleandclip {scaleandclip} \scaleandclip

\setupscaleandclip
  [width=\textwidth,
   height=\textheight]

\unexpanded\def\scaleandclip{\dodoubleempty\doscaleandclip}

\def\doscaleandclip[#1][#2]%
  {\bgroup
   \ifsecondargument
  \edef\currentscaleandclip{#1}%
  \setupcurrentscaleandclip[#2]%
   \else\iffirstargument
  \doifassignmentelse{#1}
  {\let\currentscaleandclip\empty
   \setupcurrentscaleandclip[#1]}
  {\edef\currentscaleandclip{#1}}
\else
  \let\currentscaleandclip\empty
\fi\fi
\dowithnextboxcs\scaleandclip_finish\hbox}

\def\scaleandclip_finish
{%
  \d_scaleandclip_requested_wd \dimexpr\scaleandclipparameter\c!width\relax
  \d_scaleandclip_requested_ht \dimexpr\scaleandclipparameter\c!height\relax
  %
  \d_scaleandclip_actual_wd\wd\nextbox
  \d_scaleandclip_actual_ht\dimexpr\ht\nextbox + \dp\nextbox\relax
  %
  \ifdim\dimexpr\d_scaleandclip_actual_wd*100/\d_scaleandclip_requested_wd <
\dimexpr\d_scaleandclip_actual_ht*100/\d_scaleandclip_requested_ht 
\relax
\setbox\scaleandclip_box\hbox
{\scale[\c!width=\d_scaleandclip_requested_wd]{\box\nextbox}}%
\scratchdimen=\the\dimexpr(\ht\scaleandclip_box - 
\d_scaleandclip_requested_ht)/2\relax
\clip
  [
\c!voffset=\scratchdimen,
\c!height=\d_scaleandclip_requested_ht,
  ]{\box\scaleandclip_box}%
  \else
\setbox\scaleandclip_box\hbox
{\scale[\c!height=\d_scaleandclip_requested_ht]{\box\nextbox}}%
\scratchdimen=\the\dimexpr(\wd\scaleandclip_box - 
\d_scaleandclip_requested_wd)/2\relax
\clip
  [
\c!hoffset=\scratchdimen,
\c!width=\d_scaleandclip_requested_wd,
  ]{\box\scaleandclip_box}%
  \fi
  \egroup}

\protect

The usage is:

\scaleandclip[width=..., height=...]{ ... any box ...}

simimlar to the usage of \scale macro.


\starttext

\dontleavehmode
\scaleandclip[width=3cm, 
height=3cm]{\externalfigure[cow.pdf][width=3cm,frame=on]}
\scale[maxwidth=3cm, 
maxheight=3cm]{\externalfigure[cow.pdf][width=3cm,frame=on]}

\dontleavehmode
\scaleandclip[width=3cm, 
height=3cm]{\externalfigure[cow.pdf][width=3cm,height=10cm,frame=on]}
\scale[maxwidth=3cm, 
maxheight=3cm]{\externalfigure[cow.pdf][width=3cm,height=10cm,frame=on]}

\dontleavehmode
\scaleandclip[width=3cm, 
height=3cm]{\externalfigure[cow.pdf][width=10cm,height=3cm,frame=on]}
\scale[maxwidth=3cm, 
maxheight=3cm]{\externalfigure[cow.pdf][width=10cm,height=3cm,frame=on]}

\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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Otared Kavian
Hi Mikael,

With your new definitions and lua code I could typeset and test a few examples: 
it is very nice, thanks for sharing!

Best regards: OK

On 1 mai 2014, at 17:07, Mikael P. Sundqvist  wrote:

> Interesting,
> 
> I use ConTeXt  ver: 2014.04.28 23:24 MKIV beta  fmt: 2014.4.29  int:
> english/english
> 
> and it works. I now defined this with argument:
> 
> \startluacode
> userdata = userdata or {}
> function userdata.lundklippfyllbild(str, bredd, hojd)
> if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
>  local skalning =
> -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
>  context("\\vskip%ssp", skalning)
>  context.externalfigure({str},{width=bredd})
>  context.sprint("foo")
> else
>  local skalning =
> -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
>  context("\\hskip%ssp", skalning)
>  context.externalfigure({str},{height=hojd})
>  context.sprint("bar")
> end
> end
> \stopluacode
> 
> \unexpanded\def\lundklippfyllbild#1#2#3{%
> \startexternalfigurecollection[#1]%
> \useexternalfigure[#1][#1]%
> \stopexternalfigurecollection%
> \clip[
> width=#2,
> height=#3,
> hoffset=0mm,
> voffset=0mm,
> ]{%
> \framed[width=#2,height=#3,align={middle,lohi},offset=overlay,frame=off]{%
> \dimen0=\externalfigurecollectionminwidth{#1}%
> \dimen2=\externalfigurecollectionmaxheight{#1}%
> \dimen4=#2%
> \dimen6=#3%
> {\ctxlua{userdata.lundklippfyllbild([==[#1]==],[==[#2]==],[==[#3]==])}
> 
> 
> 
> and then run
> 
> 
> \lundklippfyllbild{k.jpg}{\textwidth}{\textheight}
> 
> 
> it works well. Of course you should replace k.jpg with some other image 
> name...
> 
> /Mikael
> 
> PS And please, if someone has opinions about the code, don't hesitate
> to tell me. This is my first time using lua...
> 
> 
> On Thu, May 1, 2014 at 4:59 PM, Otared Kavian  wrote:
>> Hi Mikael,
>> 
>> Out of curiosity I tried to typeset your example (after adding the usual 
>> \starttext, \stoptext), but using
>>ConTeXt  ver: 2014.04.28 23:24 MKIV beta  fmt: 2014.4.29  int: 
>> english/english
>> I obtained a TeX error:
>> 
>> tex error   > error on line 13 in file 
>> /Users/kavian/Context/essais/mkii/figures/resize-and-center.tex: ! Undefined 
>> control sequence
>> 
>> 
>> \startexternalfigurecollection ...igurecollection
>>  {#1}\settrue 
>> \c_grph_inclu...
>> l.13 \clip[width=8cm,height=7cm]
>>  {%
>> 
>> 3 \startexternalfigurecollection[k.jpg]
>> 4 \useexternalfigure[k.jpg][k.jpg]
>> 5 \stopexternalfigurecollection
>> 
>> I did not understand what is the « Undefined control sequence », since I 
>> think \clip is a known control sequence.
>> 
>> Best regards: OK
>> 
>> On 1 mai 2014, at 15:38, Mikael P. Sundqvist  wrote:
>> 
>>> OK, sorry for the noise. I think I have the solution:
>>> 
>>> \startexternalfigurecollection[k.jpg]
>>>\useexternalfigure[k.jpg][k.jpg]
>>> \stopexternalfigurecollection
>>> 
>>> 
>>> \externalfigurecollectionminwidth{k.jpg}
>>> \externalfigurecollectionmaxheight{k.jpg}
>>> 
>>> \clip[width=8cm,height=7cm]{%
>>> \framed[width=8cm,height=7cm,align={middle,lohi},offset=overlay]{%
>>> \dimen0=\externalfigurecollectionminwidth{k.jpg}
>>> \dimen2=\externalfigurecollectionmaxheight{k.jpg}
>>> \dimen4=8cm
>>> \dimen6=7cm
>>> \startluacode
>>> if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
>>> local skalning =
>>> -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
>>> context("\\vskip%ssp", skalning)
>>> context.externalfigure({"k.jpg"},{width="8cm"})
>>> context.sprint("foo")
>>> else
>>> local skalning =
>>> -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
>>> context("\\hskip%ssp", skalning)
>>> context.externalfigure({"k.jpg"},{height="7cm"})
>>> context.sprint("bar")
>>> end
>>> \stopluacode
>>> }}
>>> 
>>> If there are any bad side effects of this or simplifications, please
>>> do not hesitate to tell me :)
>>> 
>>> /Mikael
>>> 
>>> On Thu, May 1, 2014 at 1:50 PM, Mikael P. Sundqvist  
>>> wrote:
 Hi!
 
 Assume that I want to fill in the text area with images, and I want to
 clip and scale them according to these rules:
 
 1) If the image is "too wide" (in sense of proportions), then scale it
 so that the height fits the text area height, center it, and clip it
 to the text area. (See the attached image, on top, where the blue area
 is supposed to show the text area and the red rectangle the image.)
 
 2) If the image is "too high" (in sense of proportions), then scale it
 so that the width fits the text area width, center it, and clip it to
 the text area. (See the attached image, on bottom.)
 
 The background why I want to do this is that I'm making a small
 template for presentations, and I'd like the users to insert images as
 background without really having to think about if their proportions

Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Mikael P. Sundqvist
Interesting,

I use ConTeXt  ver: 2014.04.28 23:24 MKIV beta  fmt: 2014.4.29  int:
english/english

and it works. I now defined this with argument:

\startluacode
userdata = userdata or {}
function userdata.lundklippfyllbild(str, bredd, hojd)
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
  local skalning =
-0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
  context("\\vskip%ssp", skalning)
  context.externalfigure({str},{width=bredd})
  context.sprint("foo")
else
  local skalning =
-0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
  context("\\hskip%ssp", skalning)
  context.externalfigure({str},{height=hojd})
  context.sprint("bar")
end
end
\stopluacode

\unexpanded\def\lundklippfyllbild#1#2#3{%
\startexternalfigurecollection[#1]%
\useexternalfigure[#1][#1]%
\stopexternalfigurecollection%
\clip[
width=#2,
height=#3,
hoffset=0mm,
voffset=0mm,
]{%
\framed[width=#2,height=#3,align={middle,lohi},offset=overlay,frame=off]{%
\dimen0=\externalfigurecollectionminwidth{#1}%
\dimen2=\externalfigurecollectionmaxheight{#1}%
\dimen4=#2%
\dimen6=#3%
{\ctxlua{userdata.lundklippfyllbild([==[#1]==],[==[#2]==],[==[#3]==])}



and then run


\lundklippfyllbild{k.jpg}{\textwidth}{\textheight}


it works well. Of course you should replace k.jpg with some other image name...

/Mikael

PS And please, if someone has opinions about the code, don't hesitate
to tell me. This is my first time using lua...


On Thu, May 1, 2014 at 4:59 PM, Otared Kavian  wrote:
> Hi Mikael,
>
> Out of curiosity I tried to typeset your example (after adding the usual 
> \starttext, \stoptext), but using
> ConTeXt  ver: 2014.04.28 23:24 MKIV beta  fmt: 2014.4.29  int: 
> english/english
> I obtained a TeX error:
>
> tex error   > error on line 13 in file 
> /Users/kavian/Context/essais/mkii/figures/resize-and-center.tex: ! Undefined 
> control sequence
>
>
> \startexternalfigurecollection ...igurecollection
>   {#1}\settrue 
> \c_grph_inclu...
> l.13 \clip[width=8cm,height=7cm]
>   {%
>
>  3 \startexternalfigurecollection[k.jpg]
>  4 \useexternalfigure[k.jpg][k.jpg]
>  5 \stopexternalfigurecollection
>
> I did not understand what is the « Undefined control sequence », since I 
> think \clip is a known control sequence.
>
> Best regards: OK
>
> On 1 mai 2014, at 15:38, Mikael P. Sundqvist  wrote:
>
>> OK, sorry for the noise. I think I have the solution:
>>
>> \startexternalfigurecollection[k.jpg]
>> \useexternalfigure[k.jpg][k.jpg]
>> \stopexternalfigurecollection
>>
>>
>> \externalfigurecollectionminwidth{k.jpg}
>> \externalfigurecollectionmaxheight{k.jpg}
>>
>> \clip[width=8cm,height=7cm]{%
>> \framed[width=8cm,height=7cm,align={middle,lohi},offset=overlay]{%
>> \dimen0=\externalfigurecollectionminwidth{k.jpg}
>> \dimen2=\externalfigurecollectionmaxheight{k.jpg}
>> \dimen4=8cm
>> \dimen6=7cm
>> \startluacode
>> if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
>>  local skalning =
>> -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
>>  context("\\vskip%ssp", skalning)
>>  context.externalfigure({"k.jpg"},{width="8cm"})
>>  context.sprint("foo")
>> else
>>  local skalning =
>> -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
>>  context("\\hskip%ssp", skalning)
>>  context.externalfigure({"k.jpg"},{height="7cm"})
>>  context.sprint("bar")
>> end
>> \stopluacode
>> }}
>>
>> If there are any bad side effects of this or simplifications, please
>> do not hesitate to tell me :)
>>
>> /Mikael
>>
>> On Thu, May 1, 2014 at 1:50 PM, Mikael P. Sundqvist  wrote:
>>> Hi!
>>>
>>> Assume that I want to fill in the text area with images, and I want to
>>> clip and scale them according to these rules:
>>>
>>> 1) If the image is "too wide" (in sense of proportions), then scale it
>>> so that the height fits the text area height, center it, and clip it
>>> to the text area. (See the attached image, on top, where the blue area
>>> is supposed to show the text area and the red rectangle the image.)
>>>
>>> 2) If the image is "too high" (in sense of proportions), then scale it
>>> so that the width fits the text area width, center it, and clip it to
>>> the text area. (See the attached image, on bottom.)
>>>
>>> The background why I want to do this is that I'm making a small
>>> template for presentations, and I'd like the users to insert images as
>>> background without really having to think about if their proportions
>>> fit or not.
>>>
>>> Best regards, Mikael
>> ___
>> 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://tex.aanhet.net
>> archive  : http://foundry.supelec.fr

Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Otared Kavian
Hi Mikael,

Out of curiosity I tried to typeset your example (after adding the usual 
\starttext, \stoptext), but using 
ConTeXt  ver: 2014.04.28 23:24 MKIV beta  fmt: 2014.4.29  int: 
english/english 
I obtained a TeX error:

tex error   > error on line 13 in file 
/Users/kavian/Context/essais/mkii/figures/resize-and-center.tex: ! Undefined 
control sequence


\startexternalfigurecollection ...igurecollection 
  {#1}\settrue \c_grph_inclu...
l.13 \clip[width=8cm,height=7cm]
  {%

 3 \startexternalfigurecollection[k.jpg]
 4 \useexternalfigure[k.jpg][k.jpg]
 5 \stopexternalfigurecollection

I did not understand what is the « Undefined control sequence », since I think 
\clip is a known control sequence.

Best regards: OK

On 1 mai 2014, at 15:38, Mikael P. Sundqvist  wrote:

> OK, sorry for the noise. I think I have the solution:
> 
> \startexternalfigurecollection[k.jpg]
> \useexternalfigure[k.jpg][k.jpg]
> \stopexternalfigurecollection
> 
> 
> \externalfigurecollectionminwidth{k.jpg}
> \externalfigurecollectionmaxheight{k.jpg}
> 
> \clip[width=8cm,height=7cm]{%
> \framed[width=8cm,height=7cm,align={middle,lohi},offset=overlay]{%
> \dimen0=\externalfigurecollectionminwidth{k.jpg}
> \dimen2=\externalfigurecollectionmaxheight{k.jpg}
> \dimen4=8cm
> \dimen6=7cm
> \startluacode
> if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
>  local skalning =
> -0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
>  context("\\vskip%ssp", skalning)
>  context.externalfigure({"k.jpg"},{width="8cm"})
>  context.sprint("foo")
> else
>  local skalning =
> -0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
>  context("\\hskip%ssp", skalning)
>  context.externalfigure({"k.jpg"},{height="7cm"})
>  context.sprint("bar")
> end
> \stopluacode
> }}
> 
> If there are any bad side effects of this or simplifications, please
> do not hesitate to tell me :)
> 
> /Mikael
> 
> On Thu, May 1, 2014 at 1:50 PM, Mikael P. Sundqvist  wrote:
>> Hi!
>> 
>> Assume that I want to fill in the text area with images, and I want to
>> clip and scale them according to these rules:
>> 
>> 1) If the image is "too wide" (in sense of proportions), then scale it
>> so that the height fits the text area height, center it, and clip it
>> to the text area. (See the attached image, on top, where the blue area
>> is supposed to show the text area and the red rectangle the image.)
>> 
>> 2) If the image is "too high" (in sense of proportions), then scale it
>> so that the width fits the text area width, center it, and clip it to
>> the text area. (See the attached image, on bottom.)
>> 
>> The background why I want to do this is that I'm making a small
>> template for presentations, and I'd like the users to insert images as
>> background without really having to think about if their proportions
>> fit or not.
>> 
>> Best regards, Mikael
> ___
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] resize and center and clip image

2014-05-01 Thread Mikael P. Sundqvist
OK, sorry for the noise. I think I have the solution:

\startexternalfigurecollection[k.jpg]
 \useexternalfigure[k.jpg][k.jpg]
 \stopexternalfigurecollection


\externalfigurecollectionminwidth{k.jpg}
\externalfigurecollectionmaxheight{k.jpg}

\clip[width=8cm,height=7cm]{%
\framed[width=8cm,height=7cm,align={middle,lohi},offset=overlay]{%
\dimen0=\externalfigurecollectionminwidth{k.jpg}
\dimen2=\externalfigurecollectionmaxheight{k.jpg}
\dimen4=8cm
\dimen6=7cm
\startluacode
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then
  local skalning =
-0.5*(tex.dimen[4]/tex.dimen[0]*tex.dimen[2]-tex.dimen[6])
  context("\\vskip%ssp", skalning)
  context.externalfigure({"k.jpg"},{width="8cm"})
  context.sprint("foo")
else
  local skalning =
-0.5*(tex.dimen[6]/tex.dimen[2]*tex.dimen[0]-tex.dimen[4])
  context("\\hskip%ssp", skalning)
  context.externalfigure({"k.jpg"},{height="7cm"})
  context.sprint("bar")
end
\stopluacode
}}

If there are any bad side effects of this or simplifications, please
do not hesitate to tell me :)

/Mikael

On Thu, May 1, 2014 at 1:50 PM, Mikael P. Sundqvist  wrote:
> Hi!
>
> Assume that I want to fill in the text area with images, and I want to
> clip and scale them according to these rules:
>
> 1) If the image is "too wide" (in sense of proportions), then scale it
> so that the height fits the text area height, center it, and clip it
> to the text area. (See the attached image, on top, where the blue area
> is supposed to show the text area and the red rectangle the image.)
>
> 2) If the image is "too high" (in sense of proportions), then scale it
> so that the width fits the text area width, center it, and clip it to
> the text area. (See the attached image, on bottom.)
>
> The background why I want to do this is that I'm making a small
> template for presentations, and I'd like the users to insert images as
> background without really having to think about if their proportions
> fit or not.
>
> Best regards, Mikael
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] resize and center and clip image

2014-05-01 Thread Mikael P. Sundqvist
Hi!

Assume that I want to fill in the text area with images, and I want to
clip and scale them according to these rules:

1) If the image is "too wide" (in sense of proportions), then scale it
so that the height fits the text area height, center it, and clip it
to the text area. (See the attached image, on top, where the blue area
is supposed to show the text area and the red rectangle the image.)

2) If the image is "too high" (in sense of proportions), then scale it
so that the width fits the text area width, center it, and clip it to
the text area. (See the attached image, on bottom.)

The background why I want to do this is that I'm making a small
template for presentations, and I'd like the users to insert images as
background without really having to think about if their proportions
fit or not.

Best regards, Mikael
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] too many open files?

2014-05-01 Thread Henning Hraban Ramm

Am 2014-05-01 um 05:13 schrieb Andrea Valle :

> Dear,
> 
> I’m compiling the new version of my manual on the SuperCollider language, 
> using a project structure, and I’m including a lot of pdfs, as I’m 
> automatically generating figures containing colorised code that have to 
> included  in the book. Btw I’m quite happy of the results! Thanks to devs for 
> your work.
> 
> Anyway, I’m stuck at this. I’m getting this error, seems related to the 
> number of included pdfs
> 
>   file '/paperiProgetti/SC/introSC/code/controlli/map.pdf': Too many open files.
> 
> !LuaTeX error: xpdf: reading PDF image failed
>  ==> Fatal error occurred, no output PDF file produced!
> 
> What can I do?

See http://wiki.contextgarden.net/LilyPond#Too_many_open_files :

*Too many open files*

With bigger projects ... you might run into "too many open files" errors, at 
least in Linux, OSX and other Unix-like OSes. 
Ask your shell about the open files maximum and set it higher:

 $ ulimit -n
 256
 ulimit -S -n 2048



Greetlings, Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___