ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \externalfigure doesn't find mps file in subdirectory
@ 2013-08-04 13:04 Sanjoy Mahajan
  2013-08-05 12:37 ` Sanjoy Mahajan
  0 siblings, 1 reply; 7+ messages in thread
From: Sanjoy Mahajan @ 2013-08-04 13:04 UTC (permalink / raw)
  To: ntg-context

\externalfigure won't find a metapost eps file in a subdirectory, if the
mps has the numerical (.1) extension.

Here's a minimal example (test.tex):

\setupexternalfigures[directory={fig}]
\starttext
\externalfigure[simple.1]
\stoptext

where fig/simple.1 is from a simple .mp file that fills a 1-cm box (see
below).  

The resulting test.pdf shows the gray box 

  name : simple.1
  file : simple.1
  state: unknown

Only this combination of circumstances triggers the problem.  Giving the
full path ("\externalfigure[fig/simple.1]") works fine, as does renaming
the file to simple.mps (within the fig/ directory), as does using
instead simple-1.pdf (made with mptopdf).

Thus, I have several workarounds, but it might be useful to figure out
what is not working.  I've noticed this problem on and off for a while
now, but only now made a minimal example.  (Is the path-searching code
trying to append extensions and directory prefixes at the same time, and
thus not finding the file?)

This is with MkIV 2013.05.28 from vanilla TL2013.

For completeness, here's simple.1, although any file will show the
problem equally well:

%!PS
%%BoundingBox: 0 0 29 29 
%%HiResBoundingBox: 0 0 28.34645 28.34645 
%%Creator: MetaPost 1.803
%%CreationDate: 2013.08.04:0841
%%Pages: 1
%%BeginProlog
%%EndProlog
%%Page: 1 1
 0 0 0 setrgbcolor
newpath 0 0 moveto
28.34645 0 lineto
28.34645 28.34645 lineto
0 28.34645 lineto
 closepath fill
showpage
%%EOF


-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
___________________________________________________________________________________


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

* Re: \externalfigure doesn't find mps file in subdirectory
  2013-08-04 13:04 \externalfigure doesn't find mps file in subdirectory Sanjoy Mahajan
@ 2013-08-05 12:37 ` Sanjoy Mahajan
  2013-08-05 21:18   ` Sietse Brouwer
  0 siblings, 1 reply; 7+ messages in thread
From: Sanjoy Mahajan @ 2013-08-05 12:37 UTC (permalink / raw)
  To: ntg-context

Sanjoy Mahajan <sanjoy@olin.edu> writes:

> \externalfigure won't find a metapost eps file in a subdirectory, if the
> mps has the numerical (.1) extension.

Here's the debugging info after enabling the graphics.locating tracker
(which I learned about at the very useful page
<http://wiki.contextgarden.net/Command/externalfigure>):

  graphics        > inclusion > forcing format '1'
  graphics        > inclusion > 'simple.1' cannot be resolved
  graphics        > inclusion > './simple.1' cannot be resolved
  graphics        > inclusion > '../simple.1' cannot be resolved
  graphics        > inclusion > '../../simple.1' cannot be resolved
  graphics        > inclusion > 'fig/simple.1' resolved to 'fig/simple.1'
  graphics        > inclusion > format '1' is not supported

-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
___________________________________________________________________________________


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

* Re: \externalfigure doesn't find mps file in subdirectory
  2013-08-05 12:37 ` Sanjoy Mahajan
@ 2013-08-05 21:18   ` Sietse Brouwer
  2013-08-05 22:00     ` Hans Hagen
  2013-08-06  7:50     ` Alan BRASLAU
  0 siblings, 2 replies; 7+ messages in thread
From: Sietse Brouwer @ 2013-08-05 21:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Sanjoy,

Sorry for the late reply; I had to dig around in grph-inc.lua, and I'm
a bit rusty at source-diving.

Yep, that’s a problem all right. A bug, even: when you put `simple.1`
in the same directory as the `.tex` file, it is correctly identified
as MetaPost; when you put the exact same file in a subdirectory like
`./fig`, you get the problem you describe. No clue why.

Until Hans fixes this, you can force ConTeXt to treat a file as
MetaPost, JPEG, etc. by passing the `method=` paramater to
`\externalfigure`. For MetaPost, write `method=mps`; I don’t know why
the MetaPost code is not `mp`. (Perhaps that could be made a synonym?)

Complete example below. I hope this workaround helps? Good luck with your work!

Cheers,
Sietse

    % test.tex
    \setupexternalfigures[directory={fig}]
    \enabletrackers[graphics.locating]

    \starttext
        \externalfigure[simple.1][width=10cm, method=mps]
    \stoptext

    % fig/simple.1
    %!PS
    %%BoundingBox: 0 0 29 29
    %%HiResBoundingBox: 0 0 28.34645 28.34645
    %%Creator: MetaPost 1.803
    %%CreationDate: 2013.08.04:0841
    %%Pages: 1
    %%BeginProlog
    %%EndProlog
    %%Page: 1 1
     0 0 0 setrgbcolor
    newpath 0 0 moveto
    28.34645 0 lineto
    28.34645 28.34645 lineto
    0 28.34645 lineto
     closepath fill
    showpage
    %%EOF
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: \externalfigure doesn't find mps file in subdirectory
  2013-08-05 21:18   ` Sietse Brouwer
@ 2013-08-05 22:00     ` Hans Hagen
  2013-08-06  9:04       ` Sietse Brouwer
  2013-08-06 12:38       ` Sanjoy Mahajan
  2013-08-06  7:50     ` Alan BRASLAU
  1 sibling, 2 replies; 7+ messages in thread
From: Hans Hagen @ 2013-08-05 22:00 UTC (permalink / raw)
  To: ntg-context

On 8/5/2013 11:18 PM, Sietse Brouwer wrote:
> Hi Sanjoy,
>
> Sorry for the late reply; I had to dig around in grph-inc.lua, and I'm
> a bit rusty at source-diving.
>
> Yep, that’s a problem all right. A bug, even: when you put `simple.1`
> in the same directory as the `.tex` file, it is correctly identified
> as MetaPost; when you put the exact same file in a subdirectory like
> `./fig`, you get the problem you describe. No clue why.
>
> Until Hans fixes this, you can force ConTeXt to treat a file as
> MetaPost, JPEG, etc. by passing the `method=` paramater to
> `\externalfigure`. For MetaPost, write `method=mps`; I don’t know why
> the MetaPost code is not `mp`. (Perhaps that could be made a synonym?)
>
> Complete example below. I hope this workaround helps? Good luck with your work!

you can test with this (line 767 in grph-inc):

             askedformat = format -- new per 2013-08-05
         elseif trace_figures then
             report_inclusion("unknown format %a",askedformat)
         end


> Cheers,
> Sietse
>
>      % test.tex
>      \setupexternalfigures[directory={fig}]
>      \enabletrackers[graphics.locating]
>
>      \starttext
>          \externalfigure[simple.1][width=10cm, method=mps]
>      \stoptext
>
>      % fig/simple.1
>      %!PS
>      %%BoundingBox: 0 0 29 29
>      %%HiResBoundingBox: 0 0 28.34645 28.34645
>      %%Creator: MetaPost 1.803
>      %%CreationDate: 2013.08.04:0841
>      %%Pages: 1
>      %%BeginProlog
>      %%EndProlog
>      %%Page: 1 1
>       0 0 0 setrgbcolor
>      newpath 0 0 moveto
>      28.34645 0 lineto
>      28.34645 28.34645 lineto
>      0 28.34645 lineto
>       closepath fill
>      showpage
>      %%EOF
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: \externalfigure doesn't find mps file in subdirectory
  2013-08-05 21:18   ` Sietse Brouwer
  2013-08-05 22:00     ` Hans Hagen
@ 2013-08-06  7:50     ` Alan BRASLAU
  1 sibling, 0 replies; 7+ messages in thread
From: Alan BRASLAU @ 2013-08-06  7:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 5 Aug 2013 23:18:41 +0200
Sietse Brouwer <sbbrouwer@gmail.com> wrote:

> For MetaPost, write `method=mps`; I don’t know why
> the MetaPost code is not `mp`. (Perhaps that could be made a synonym?)

I suppose because `mp' is MetaPost code
and `mps' is MetaPost produced PostScript.

Alan
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: \externalfigure doesn't find mps file in subdirectory
  2013-08-05 22:00     ` Hans Hagen
@ 2013-08-06  9:04       ` Sietse Brouwer
  2013-08-06 12:38       ` Sanjoy Mahajan
  1 sibling, 0 replies; 7+ messages in thread
From: Sietse Brouwer @ 2013-08-06  9:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> you can test with this (line 767 in grph-inc):
>
>             askedformat = format -- new per 2013-08-05
>         elseif trace_figures then
>             report_inclusion("unknown format %a",askedformat)
>         end

That fixes the problem, hooray! \o/

Cheers,
Sietse
___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: \externalfigure doesn't find mps file in subdirectory
  2013-08-05 22:00     ` Hans Hagen
  2013-08-06  9:04       ` Sietse Brouwer
@ 2013-08-06 12:38       ` Sanjoy Mahajan
  1 sibling, 0 replies; 7+ messages in thread
From: Sanjoy Mahajan @ 2013-08-06 12:38 UTC (permalink / raw)
  To: ntg-context

Hans, Sietse,

Thank you very much: method=mps works, as does Hans's lua code.

Best,
-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
___________________________________________________________________________________


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

end of thread, other threads:[~2013-08-06 12:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-04 13:04 \externalfigure doesn't find mps file in subdirectory Sanjoy Mahajan
2013-08-05 12:37 ` Sanjoy Mahajan
2013-08-05 21:18   ` Sietse Brouwer
2013-08-05 22:00     ` Hans Hagen
2013-08-06  9:04       ` Sietse Brouwer
2013-08-06 12:38       ` Sanjoy Mahajan
2013-08-06  7:50     ` Alan BRASLAU

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).