Google Groups Home
Help | Sign in
pdflatex and url
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Ralph Menikoff  
View profile
 More options May 18, 2:21 pm
From: Ralph Menikoff <rmenik...@uswest.net>
Date: Sun, 18 May 2008 12:21:24 -0600
Local: Sun, May 18 2008 2:21 pm
Subject: pdflatex and url

I have been using pdflatex with amrita widget macros.
The hyperref package (used for amrita widgets) has a macro \href
which allows one to put link to url in pdf file.
Then user can simply click on url and acroread
should open web browser to that web page.
This works fine when \href is used directly on a page
but not from a widget.
Does this have to do with amrita widget macros
or is it a limitation of acroread ?
I am using Amrita version 3.00 (release 14-03-2006)
Test script that demonstrates the effect is attached.

[ latextest 6K ]
fold::amrita { procedures
   fold::amrita { LatexSlideHead
     proc LatexSlideHead {
          file
        }
        fold::amrita { define procedures
           fold::amrita { color support routines
              fold::perl { expand::latex::color
                 sub expand::latex::color {
                    my $arg = shift;
                    $h = '([0-9a-f]{2,2})';
                    if($arg =~ /^\s*(\w+)\s*=\s*0x$h$h$h\/0x$h$h$h/i) {
                       my $name = lc($1);
                       my ($r,$g,$b) = ($2,$3,$4);
                       my $NAME = uc($1);
                       my ($R,$G,$B) = ($5,$6,$7);
                       $amrita->set_token("color::$name","0x$r$g$b");
                       $amrita->set_token("color::$NAME","0x$R$G$B");
                       fold::perl { convert to decimal
                          $r = sprintf("%.2f",hex($r)/255);
                          $g = sprintf("%.2f",hex($g)/255);
                          $b = sprintf("%.2f",hex($b)/255);
                          $R = sprintf("%.2f",hex($R)/255);
                          $G = sprintf("%.2f",hex($G)/255);
                          $B = sprintf("%.2f",hex($B)/255);
                       }
                       "\\definecolor{$name}{rgb}{$r,$g,$b}%\n".
                       "\\definecolor{$NAME}{rgb}{$R,$G,$B}%\n";
                    }
                    else {
                       $amrita->error("latex::color, expect argument: name=0xhhhhhh/0xhhhhhh");
                    }
                 }
              }
           }
        }
        Latex2eHead {
           fold::amrita { parameters
              file      = $file
              amrpdf    = yes
              font      = deferPlainLatex
              fold::param'moretopmatter {
                 fold>guard=|,dollar off
                 fold::latex { define colors
                   &latex::color(normal  =0x1c1c8c/0x1c8c1c)
                   &latex::color(rollover=0x8c1c1c/0x8c1c1c)
                   &latex::color(down    =0x1c8c1c/0x1c1c8c)
                   %
                   &latex::rgb(pbackground=0xf5efdd)
                   &latex::rgb(ptext=0x401022)
                   &latex::color(pnormal  =0x1c1c8c/0x1c8c1c)
                   &latex::color(prollover=0x8c1c1c/0x8c1c1c)
                   &latex::color(pdown    =0x1c8c1c/0x1c1c8c)
                   %
                   &latex::rgb(background=0xffffcc) % H60 S20 B100, CMY=(0,0,51)
                   &latex::rgb(text=0x000033)
                   &latex::rgb(pbackground=0xfff7cc)% H50 S20 B100, CMY=(0,8,51)
                   &latex::rgb(ptext=0x000833)
                 }
              }
           }
        }
        fold::latex { initialize openWidgets
          fold>file.=$amrita:latex::file`OpenAction
           var openWidgets  = ['','',''];
           var currentPoint = ['','',''];
           var imax=2;
           fold::latex { RunPopOn
              function RunPopOn(i,wids) {
                 for(j=imax;i<j;j--) {
                   amrHideWidgets(openWidgets[j]);
                   openWidgets[j] = '';
                   currentPoint[j].value = 'Off';
                 }
                 if( openWidgets[i] != '' ) {
                   amrHideWidgets(openWidgets[i]);
                   currentPoint[i].value = 'Off';
                 }
                 fold::latex { lose focus
                    f = event.target;
                    f.hidden = true;
                    f.hidden = false;
                 }
                 if(f.value == 'On') {
                    currentPoint[i] = f;
                    openWidgets[i]  = wids;
                    amrShowWidgets(openWidgets[i]);
                 }
                 else {
                    openWidgets[i]  = '';
                 }
              }
           }
           fold::latex { RunPopOff
              function RunPopOff(i) {
                 for(j=imax;i<=j;j--) {
                    if(openWidgets[j] != '') {
                       amrHideWidgets(openWidgets[j]);
                       openWidgets[j] = '';
                       if(currentPoint[j]) {
                          currentPoint[j].value = 'Off';
                       }
                    }
                 }
              }
           }
        }
        fold::latex { set style
           \pagestyle{empty}
           \pagecolor{background}
           \color{text}
        }
     end proc
   }
   fold::amrita { AddPoint
     proc AddPoint {
          fold::amrita { parameters
             item      = $?amrita:fold:caller::comment
             elaborate
             width     = 250pt
             x         = 550
             y         = 545
             level     = +1
             margin    = 10pt
          }
        }
        fold::latex { define widgets
           fold::amrita { elaborate shadow box
              if( token(elaborate) ) then
                 fold::latex { add shadowbox
                    \amrBeginWidgets
                      fold::latex { get handler
                        fold> token=handler
                          group      Point::group
                          status     closed
                          level      *level
                          appearance {normal}
                          U::js      RunPopOff(0);
                          inline     upper-right  (*x,*y)
                      }
                      &latex::widget(handler){%
                        \color{ptext}%
                        \amrAddShadowBox[t][*width]<*margin,pbackground>{
                            fold::amrita { evaluate elaborate
                               parse <token> elaborate <using> fold::latex
                            }
                        }%
                      }
                    \amrEndWidgets
                 }
              endif
           }
           fold::latex { item
              fold::latex { get handler
                fold>token=handler
                  status      open
                  level       *level
                  appearance  {normal on/Off, rollover on/Off, down on/Off}
                  normal      is ?/*color::normal
                  down        is normal|.*color::DOWN/*color::down
                  rollover    is normal|.*color::ROLLOVER/*color::rollover
                  U::js       RunPopOn(0,"*Point::group");
              }
              &latex::widget(handler){\color{NORMAL}*item}%
           }
        }
     end proc
   }

}

LatexSlideHead file=test
fold::latex { url
   \noindent
   Test of url from pdf file\\
   url \href{http://www.amrita-ebook.org/}{amrita-ebook.org}\\
   end test\\
}

fold::amrita { click to open widget
   AddPoint {
      fold::param'elaborate {
         test url from widget\\\\
         url \href{http://www.amrita-ebook.org/}{amrita-ebook.org}\\\\
         end test
      }
      width = 200pt
   }
}

LatexTail
Latex

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Quirk  
View profile
 More options May 18, 7:46 pm
From: James Quirk <j...@galcit.caltech.edu>
Date: Sun, 18 May 2008 16:46:22 -0700 (PDT)
Local: Sun, May 18 2008 7:46 pm
Subject: Re: pdflatex and url
Ralph,

On Sun, 18 May 2008, Ralph Menikoff wrote:
> I have been using pdflatex with amrita widget macros.
> The hyperref package (used for amrita widgets) has a macro \href
> which allows one to put link to url in pdf file.
> Then user can simply click on url and acroread
> should open web browser to that web page.
> This works fine when \href is used directly on a page
> but not from a widget.

If you want a widget to access a url then you should
add the following to the widget's handler:

 <event>::url {url1, url2, ..., urln}

Thus to mimic href you would trigger off a mouse up event, as in:

fold::latex {
   fold> token=handler
   U::url {http://www.amrita-ebook.org}

}

&latex::widget(handler){Click me!}

The above is more cumbersome than using href, but there is
nothing to stop you from writing your own wrapper, such
that you can call:

  \myhref{url}

and have it invoke a TeX macro created by latex::widget.
This will then allow you to access functionality that
goes well beyond that of hyperref.

Note that given the way pdflatex works PDF annotations cannot
be nested and so if you use \href in the appearance of
a latex::widget then the associated hyperref machinery is
switched off.

James


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ralph Menikoff  
View profile
 More options May 18, 10:41 pm
From: Ralph Menikoff <rmenik...@uswest.net>
Date: Sun, 18 May 2008 20:41:55 -0600
Local: Sun, May 18 2008 10:41 pm
Subject: Re: pdflatex and url

OK, attached is revised script which does what I wanted.
By the way, how do I get attachment to show up
as link to click on rather than fully expanded text ?

[ latextest 7K ]
fold::amrita { procedures
   fold::amrita { LatexSlideHead
     proc LatexSlideHead {
          file
        }
        fold::amrita { define procedures
           fold::amrita { color support routines
              fold::perl { expand::latex::color
                 sub expand::latex::color {
                    my $arg = shift;
                    $h = '([0-9a-f]{2,2})';
                    if($arg =~ /^\s*(\w+)\s*=\s*0x$h$h$h\/0x$h$h$h/i) {
                       my $name = lc($1);
                       my ($r,$g,$b) = ($2,$3,$4);
                       my $NAME = uc($1);
                       my ($R,$G,$B) = ($5,$6,$7);
                       $amrita->set_token("color::$name","0x$r$g$b");
                       $amrita->set_token("color::$NAME","0x$R$G$B");
                       fold::perl { convert to decimal
                          $r = sprintf("%.2f",hex($r)/255);
                          $g = sprintf("%.2f",hex($g)/255);
                          $b = sprintf("%.2f",hex($b)/255);
                          $R = sprintf("%.2f",hex($R)/255);
                          $G = sprintf("%.2f",hex($G)/255);
                          $B = sprintf("%.2f",hex($B)/255);
                       }
                       "\\definecolor{$name}{rgb}{$r,$g,$b}%\n".
                       "\\definecolor{$NAME}{rgb}{$R,$G,$B}%\n";
                    }
                    else {
                       $amrita->error("latex::color, expect argument: name=0xhhhhhh/0xhhhhhh");
                    }
                 }
              }
           }
        }
        Latex2eHead {
           fold::amrita { parameters
              file      = $file
              amrpdf    = yes
              font      = deferPlainLatex
              fold::param'moretopmatter {
                 fold>guard=|,dollar off
                 fold::latex { define colors
                   &latex::color(normal  =0x1c1c8c/0x1c8c1c)
                   &latex::color(rollover=0x8c1c1c/0x8c1c1c)
                   &latex::color(down    =0x1c8c1c/0x1c1c8c)
                   %
                   &latex::rgb(pbackground=0xf5efdd)
                   &latex::rgb(ptext=0x401022)
                   &latex::color(pnormal  =0x1c1c8c/0x1c8c1c)
                   &latex::color(prollover=0x8c1c1c/0x8c1c1c)
                   &latex::color(pdown    =0x1c8c1c/0x1c1c8c)
                   %
                   &latex::rgb(background=0xffffcc) % H60 S20 B100, CMY=(0,0,51)
                   &latex::rgb(text=0x000033)
                   &latex::rgb(pbackground=0xfff7cc)% H50 S20 B100, CMY=(0,8,51)
                   &latex::rgb(ptext=0x000833)
                 }
              }
           }
        }
        fold::latex { initialize openWidgets
          fold>file.=$amrita:latex::file`OpenAction
           var openWidgets  = ['','',''];
           var currentPoint = ['','',''];
           var imax=2;
           fold::latex { RunPopOn
              function RunPopOn(i,wids) {
                 for(j=imax;i<j;j--) {
                   amrHideWidgets(openWidgets[j]);
                   openWidgets[j] = '';
                   currentPoint[j].value = 'Off';
                 }
                 if( openWidgets[i] != '' ) {
                   amrHideWidgets(openWidgets[i]);
                   currentPoint[i].value = 'Off';
                 }
                 fold::latex { lose focus
                    f = event.target;
                    f.hidden = true;
                    f.hidden = false;
                 }
                 if(f.value == 'On') {
                    currentPoint[i] = f;
                    openWidgets[i]  = wids;
                    amrShowWidgets(openWidgets[i]);
                 }
                 else {
                    openWidgets[i]  = '';
                 }
              }
           }
           fold::latex { RunPopOff
              function RunPopOff(i) {
                 for(j=imax;i<=j;j--) {
                    if(openWidgets[j] != '') {
                       amrHideWidgets(openWidgets[j]);
                       openWidgets[j] = '';
                       if(currentPoint[j]) {
                          currentPoint[j].value = 'Off';
                       }
                    }
                 }
              }
           }
        }
        fold::latex { set style
           \pagestyle{empty}
           \pagecolor{background}
           \color{text}
        }
     end proc
   }
   fold::amrita { AddPoint
     proc AddPoint {
          fold::amrita { parameters
             item      = $?amrita:fold:caller::comment
             elaborate
             width     = 250pt
             x         = 550
             y         = 545
             level     = +1
             margin    = 10pt
          }
        }
        fold::latex { define widgets
           fold::amrita { elaborate shadow box
              if( token(elaborate) ) then
                 fold::latex { add shadowbox
                    \amrBeginWidgets
                      fold::latex { get handler
                        fold> token=handler
                          group      Point::group
                          status     closed
                          level      *level
                          appearance {normal}
                          U::js      RunPopOff(0);
                          inline     upper-right  (*x,*y)
                      }
                      &latex::widget(handler){%
                        \color{ptext}%
                        \amrAddShadowBox[t][*width]<*margin,pbackground>{
                            fold::amrita { evaluate elaborate
                               parse <token> elaborate <using> fold::latex
                            }
                        }%
                      }
                    \amrEndWidgets
                 }
              endif
           }
           fold::latex { item
              fold::latex { get handler
                fold>token=handler
                  status      open
                  level       *level
                  appearance  {normal on/Off, rollover on/Off, down on/Off}
                  normal      is ?/*color::normal
                  down        is normal|.*color::DOWN/*color::down
                  rollover    is normal|.*color::ROLLOVER/*color::rollover
                  U::js       RunPopOn(0,"*Point::group");
              }
              &latex::widget(handler){\color{NORMAL}*item}%
           }
        }
     end proc
   }
   fold::amrita { url
     proc url{
          fold::amrita { parameters
              url
              text
              group = Point::group
              level = +1
          }
        }
         fold::latex { url
            fold::latex { handler
               fold> token=url::handler
                 group     *group
                 status    closed
                 level     *level
                 U::uri    {*url}
                 hint      *url
            }
            &latex::widget(url::handler){\color{blue}{*text}}%
         }
     end proc
   }

}

LatexSlideHead file=test
fold::latex { url
   \noindent
   Test of url from pdf file\\
   url \href{http://www.amrita-ebook.org/}{amrita-ebook.org}\\
   end test\\
}

fold::amrita { click to open widget
   AddPoint {
      fold::param'elaborate {
      fold>guard=|, dollar off
         test url from widget\\
         fold::amrita { add url
           url {
             text = amrita-ebook.org
             url  = http://www.amrita-ebook.org/
           }
         }
         \\
         end test
      }
      width = 200pt
   }
}

LatexTail
Latex

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Quirk  
View profile
 More options May 19, 11:03 am
From: James Quirk <j...@galcit.caltech.edu>
Date: Mon, 19 May 2008 08:03:10 -0700 (PDT)
Local: Mon, May 19 2008 11:03 am
Subject: Re: pdflatex and url

On Sun, 18 May 2008, Ralph Menikoff wrote:
> OK, attached is revised script which does what I wanted.
> By the way, how do I get attachment to show up
> as link to click on rather than fully expanded text ?

I'm not sure I follow what you want. Can you elaborate?

James


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Quirk  
View profile
 More options May 19, 2:48 pm
From: James Quirk <j...@galcit.caltech.edu>
Date: Mon, 19 May 2008 11:48:22 -0700 (PDT)
Local: Mon, May 19 2008 2:48 pm
Subject: Re: pdflatex and url
Ralph,

> On Sun, 18 May 2008, Ralph Menikoff wrote:

> > OK, attached is revised script which does what I wanted.

I was just going over you script and I notice you're
using:

fold::latex {
   fold>file.=$amrita:latex::file`OpenAction

}

to write JavaScript to the OpenAction file maintained
by Latex2eHead. The preferred way to do this is actually:

fold::latex {
   fold> stream.OpenAction

}

James

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google