Entry
TSE: Subml: URL: Create: PDF: How to create clickable url in PDF, via LaTeX? [http://www / hyperref]
Mar 28th, 2005 09:12
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 27 March 2005 - 08:23 pm ----------------------
TSE: Subml: URL: Create: PDF: How to create clickable url in PDF, via
LaTeX? [http://www / hyperref]
---
Steps: Overview:
1. -The source code that should be generated by SubML for
LaTeX is e.g. the following:
--- cut here: begin --------------------------------------------------
\documentclass{article}
\usepackage[dvips, bookmarks, colorlinks=true, plainpages = false,
citecolor = green, urlcolor = blue, filecolor = blue] {hyperref}
\begin{document}
\url{ http://www.faqts.com }
\end{ document }
--- cut here: end ----------------------------------------------------
2. So add to your regurar expression search replace the
1. Add to the <BOOK> tag:
\usepackage[dvips, bookmarks, colorlinks=true, plainpages =
false, citecolor = green, urlcolor = blue, filecolor = blue] {hyperref}
2. Replace if the <URL> tag is found
<URL> by \url{
3. Replace if the </URL> tag is found
</URL> by }
3. -In TSE this becomes e.g.
1. For the <BOOK> tag:
LReplace( "\<book\>", "\\documentclass{report} \
\\usepackage\[dvips, bookmarks, colorlinks=true, plainpages = false,
citecolor = green, urlcolor = blue, filecolor = blue\]{hyperref} \
\\usepackage{makeidx} \ \\usepackage[dvips]{graphics} \ \\makeindex \
\\begin{document} \ ", searchOptionS )
2. For the <URL> tag
LReplace( "\<url\>", "\\url{", searchOptionS )
3. For the </URL> tag
LReplace( "\<\/url\>", "}", searchOptionS )
4. -Thus the new regular expression search/replace macro for
TSE becomes
--- cut here: begin --------------------------------------------------
// --- MAIN --- //
PROC Main()
PROCBlockConvertSubml2Latex()
END
<F12> Main()
// --- LIBRARY --- //
// library: block: convert: subml2: latex (filenamemacro=convblsl.s)
[kn, ri, su, 27-03-2005 07:34:23]
PROC PROCBlockConvertSubml2Latex()
// e.g. PROC Main()
// e.g. PROCBlockConvertSubml2Latex()
// e.g. END
// e.g.
// e.g. <F12> Main()
STRING searchOptionS[ 255 ] = "glxn"
LReplace( "^$", "", searchOptionS )
LReplace( "\\\/" , "\$\\backslash$", searchOptionS )
LReplace( "\$", "\\$", searchOptionS )
LReplace( "\{", "$\\{$", searchOptionS )
LReplace( "\}", "$\\}$", searchOptionS )
LReplace( "\~", "\\~{}", searchOptionS )
LReplace( "\\^", "\\^{}", searchOptionS )
LReplace( "\_", "\\_{}", searchOptionS )
LReplace( "\%", "\\%", searchOptionS )
LReplace( "\&", "\\&", searchOptionS )
LReplace( "\#", "\\#", searchOptionS )
LReplace( "\|", "$|$", searchOptionS )
LReplace( "\\\\$\\backslash\\\$", "\$\\backslash\$", searchOptionS )
LReplace( "\<a\\^{}\>", "<a^>", searchOptionS )
LReplace( "\<A\\^{}\>", "<A^>", searchOptionS )
LReplace( "\<e\\^{}\>", "<e^>", searchOptionS )
LReplace( "\<E\\^{}\>", "<E^>", searchOptionS )
LReplace( "\<i\\^{}\>", "<i^>", searchOptionS )
LReplace( "\<I\\^{}\>", "<I^>", searchOptionS )
LReplace( "\<o\\^{}\>", "<o^>", searchOptionS )
LReplace( "\<O\\^{}\>", "<O^>", searchOptionS )
LReplace( "\<u\\^{}\>", "<u^>", searchOptionS )
LReplace( "\<U\\^{}\>", "<U^>", searchOptionS )
LReplace( "\<a\\~{}\>", "<a~>", searchOptionS )
LReplace( "\<A\\~{}\>", "<A~>", searchOptionS )
LReplace( "\<n\\~{}\>", "<n~>", searchOptionS )
LReplace( "\<N\\~{}\>", "<N~>", searchOptionS )
LReplace( "\<o\\~{}\>", "<o~>", searchOptionS )
LReplace( "\<O\\~{}\>", "<O~>", searchOptionS )
LReplace( "\<comment\>", "% ", searchOptionS )
LReplace( "\<\/comment\>", "", searchOptionS )
// LReplace( "\<book\>", "\\documentclass{report} \ \\usepackage
{makeidx} \ \\usepackage[dvips]{graphics} \ \\makeindex \ \\begin
{document} \ ", searchOptionS )
LReplace( "\<book\>", "\\documentclass{report} \
\\usepackage\[dvips, bookmarks, colorlinks=true, plainpages = false,
citecolor = green, urlcolor = blue, filecolor = blue\]{hyperref} \
\\usepackage{makeidx} \ \\usepackage[dvips]{graphics} \ \\makeindex \
\\begin{document} \ ", searchOptionS )
LReplace( "\<\/book\>", "\\printindex \ \\end{document} \ \\end
{report} \ ", searchOptionS )
LReplace( "\<chapter\>", "", searchOptionS )
LReplace( "\<\/chapter\>", "", searchOptionS )
LReplace( "\<chaptertitle\>", "\\chapter{", searchOptionS )
LReplace( "\<\/chaptertitle\>", "}", searchOptionS )
LReplace( "\<section\>", "", searchOptionS )
LReplace( "\<\/section\>", "", searchOptionS )
LReplace( "\<sectiontitle\>", "\\section{", searchOptionS )
LReplace( "\<\/sectiontitle\>", "}", searchOptionS )
LReplace( "\<subsection\>", "", searchOptionS )
LReplace( "\<\/subsection\>", "", searchOptionS )
LReplace( "\<subsectiontitle\>", "\\subsection{", searchOptionS )
LReplace( "\<\/subsectiontitle\>", "}", searchOptionS )
LReplace( "\<subsubsection\>", "", searchOptionS )
LReplace( "\<\/subsubsection\>", "", searchOptionS )
LReplace( "\<subsubsectiontitle\>", "\\subsubsection{",
searchOptionS )
LReplace( "\<\/subsubsectiontitle\>", "}", searchOptionS )
LReplace( "\<para\>", " \\", searchOptionS )
LReplace( "\<\/para\>", " \\", searchOptionS )
LReplace( "\<image\>", "\\medskip \\includegraphics{",
searchOptionS )
LReplace( "\.[a-z][a-z][a-z]<\/image\>", ".eps}", searchOptionS )
LReplace( "\<image\>", "\\medskip \\includegraphics{",
searchOptionS )
LReplace( "\<\/image\>", ".eps}", searchOptionS )
LReplace( "\<quotation\>", "\\begin{quotation}", searchOptionS )
LReplace( "\<\/quotation\>", "\\end{quotation}", searchOptionS )
LReplace( "\<index\>", "\\index{", searchOptionS )
LReplace( "\<\/index\>", "}", searchOptionS )
LReplace( "\<itemize\>", "\\begin{itemize}", searchOptionS )
LReplace( "\<\/itemize\>", "\\end{itemize}", searchOptionS )
LReplace( "\<item\>", "\\item ", searchOptionS )
LReplace( "\<\/item\>", "", searchOptionS )
LReplace( "\<italic\>", "\\textit{", searchOptionS )
LReplace( "\<\/italic\>", "}", searchOptionS )
LReplace( "\<bold\>", "\\textbf{", searchOptionS )
LReplace( "\<\/bold\>", "}", searchOptionS )
LReplace( "\<underline\>", "\\underbar{", searchOptionS )
LReplace( "\<\/underline\>", "}", searchOptionS )
LReplace( "\<subscript\>", "$_{", searchOptionS )
LReplace( "\<\/subscript\>", "}$", searchOptionS )
LReplace( "\<superscript\>", "$^{", searchOptionS )
LReplace( "\<\/superscript\>", "}$", searchOptionS )
LReplace( "\<typewriter\>", "\\texttt{", searchOptionS )
LReplace( "\<\/typewriter\>", "}", searchOptionS )
LReplace( "\<literal\>", "\\begingroup \\vskip\\parskip \\everypar=
{\\nobreak} \\obeyspaces \\frenchspacing \\tt \\obeylines
\\parskip=0pt \\parindent=0pt ", searchOptionS )
LReplace( "\<\/literal\>", "\\endgroup ", searchOptionS )
// LReplace( "\<url\>", "{\\tt (", searchOptionS )
// LReplace( "\<\/url\>", ")}", searchOptionS )
LReplace( "\<url\>", "\\url{", searchOptionS )
LReplace( "\<\/url\>", "}", searchOptionS )
LReplace( "\<TeX\>", "\\TeX{}", searchOptionS )
LReplace( "\<LaTeX\>", "\\LaTeX{}", searchOptionS )
LReplace( "\<bigspace\>", "\\bigskip ", searchOptionS )
LReplace( "\<pagebreak\>", "\\vfil \\eject ", searchOptionS )
LReplace( "\<copyright\>", "\\copyright{}", searchOptionS )
LReplace( "\<angle\>", "\\angle{}", searchOptionS )
LReplace( "\<integral\>", "\$\\int{}\$", searchOptionS )
LReplace( "\<partial\>", "\$\\partial{}\$", searchOptionS )
LReplace( "\<infinity\>", "\$\\infty{}\$", searchOptionS )
LReplace( "\<minus\>", "\$-\$", searchOptionS )
LReplace( "\<doubledash\>", "\$-\$\$-\$", searchOptionS )
LReplace( "\<alpha\>", "\$\\alpha\$", searchOptionS )
LReplace( "\<beta\>", "\$\\beta\$", searchOptionS )
LReplace( "\<gamma\>", "\$\\gamma\$", searchOptionS )
LReplace( "\<GAMMA\>", "\$\\Gamma\$", searchOptionS )
LReplace( "\<delta\>", "\$\\delta\$", searchOptionS )
LReplace( "\<DELTA\>", "\$\\Delta\$", searchOptionS )
LReplace( "\<epsilon\>", "\$\\epsilon\$", searchOptionS )
LReplace( "\<varepsilon\>", "\$\\varepsilon\$", searchOptionS )
LReplace( "\<zeta\>", "\$\\zeta\$", searchOptionS )
LReplace( "\<eta\>", "\$\\eta\$", searchOptionS )
LReplace( "\<theta\>", "\$\\theta\$", searchOptionS )
LReplace( "\<THETA\>", "\$\\Theta\$", searchOptionS )
LReplace( "\<vartheta\>", "\$\\vartheta\$", searchOptionS )
LReplace( "\<iota\>", "\$\\iota\$", searchOptionS )
LReplace( "\<kappa\>", "\$\\kappa\$", searchOptionS )
LReplace( "\<lambda\>", "\$\\lambda\$", searchOptionS )
LReplace( "\<LAMBDA\>", "\$\\Lambda\$", searchOptionS )
LReplace( "\<mu\>", "\$\\mu\$", searchOptionS )
LReplace( "\<nu\>", "\$\\nu\$", searchOptionS )
LReplace( "\<xi\>", "\$\\xi\$", searchOptionS )
LReplace( "\<XI\>", "\$\\Xi\$", searchOptionS )
LReplace( "\<pi\>", "\$\\pi\$", searchOptionS )
LReplace( "\<PI\>", "\$\\Pi\$", searchOptionS )
LReplace( "\<rho\>", "\$\\rho\$", searchOptionS )
LReplace( "\<varrho\>", "\$\\varrho\$", searchOptionS )
LReplace( "\<sigma\>", "\$\\sigma\$", searchOptionS )
LReplace( "\<SIGMA\>", "\$\\Sigma\$", searchOptionS )
LReplace( "\<varsigma\>", "\$\\varsigma\$", searchOptionS )
LReplace( "\<tau\>", "\$\\tau\$", searchOptionS )
LReplace( "\<upsilon\>", "\$\\upsilon\$", searchOptionS )
LReplace( "\<UPSILON\>", "\$\\Upsilon\$", searchOptionS )
LReplace( "\<phi\>", "\$\\phi\$", searchOptionS )
LReplace( "\<PHI\>", "\$\\Phi\$", searchOptionS )
LReplace( "\<varphi\>", "\$\\varphi\$", searchOptionS )
LReplace( "\<chi\>", "\$\\chi\$", searchOptionS )
LReplace( "\<psi\>", "\$\\psi\$", searchOptionS )
LReplace( "\<PSI\>", "\$\\Psi\$", searchOptionS )
LReplace( "\<omega\>", "\$\\omega\$", searchOptionS )
LReplace( "\<OMEGA\>", "\$\\Omega\$", searchOptionS )
LReplace( "\<a`\>", "\\`a", searchOptionS )
LReplace( "\<A`\>", "\\`A", searchOptionS )
LReplace( "\<a'\>", "\\'a", searchOptionS )
LReplace( "\<A'\>", "\\'A", searchOptionS )
LReplace( "\<a^\>", "\\^a", searchOptionS )
LReplace( "\<A^\>", "\\^A", searchOptionS )
LReplace( '\<a"\>', '\\"a', searchOptionS )
LReplace( '\<A"\>', '\\"A', searchOptionS )
LReplace( "\<a~\>", "\\~a", searchOptionS )
LReplace( "\<A~\>", "\\~A", searchOptionS )
LReplace( "\<ao\>", "\\aa", searchOptionS )
LReplace( "\<Ao\>", "\\AA", searchOptionS )
LReplace( "\<c,\>", "\\c c", searchOptionS )
LReplace( "\<C,\>", "\\c C", searchOptionS )
LReplace( "\<e`\>", "\\`e", searchOptionS )
LReplace( "\<E`\>", "\\`E", searchOptionS )
LReplace( "\<e'\>", "\\'e", searchOptionS )
LReplace( "\<E'\>", "\\'E", searchOptionS )
LReplace( "\<e^\>", "\\^e", searchOptionS )
LReplace( "\<E^\>", "\\^E", searchOptionS )
LReplace( '\<e"\>', '\\"e', searchOptionS )
LReplace( '\<E"\>', '\\"E', searchOptionS )
LReplace( "\<i`\>", "\\`\\i{}", searchOptionS )
LReplace( "\<I`\>", "\\`I", searchOptionS )
LReplace( "\<i'\>", "\\'\\i{}", searchOptionS )
LReplace( "\<I'\>", "\\'I", searchOptionS )
LReplace( "\<i^\>", "\\^\\i{}", searchOptionS )
LReplace( "\<I^\>", "\\^I", searchOptionS )
LReplace( '\<i"\>', '\\"\\i{}', searchOptionS )
LReplace( '\<I"\>', '\\"I', searchOptionS )
LReplace( "\<n~\>", "\\~n", searchOptionS )
LReplace( "\<N~\>", "\\~N", searchOptionS )
LReplace( "\<o`\>", "\\`o", searchOptionS )
LReplace( "\<O`\>", "\\`O", searchOptionS )
LReplace( "\<o'\>", "\\'o", searchOptionS )
LReplace( "\<O'\>", "\\'O", searchOptionS )
LReplace( "\<o^\>", "\\^o", searchOptionS )
LReplace( "\<O^\>", "\\^O", searchOptionS )
LReplace( '\<o"\>', '\\"o', searchOptionS )
LReplace( '\<O"\>', '\\"O', searchOptionS )
LReplace( "\<o~\>", "\\~o", searchOptionS )
LReplace( "\<O~\>", "\\~O", searchOptionS )
LReplace( "\<u`\>", "\\`u", searchOptionS )
LReplace( "\<U`\>", "\\`U", searchOptionS )
LReplace( "\<u'\>", "\\'u", searchOptionS )
LReplace( "\<U'\>", "\\'U", searchOptionS )
LReplace( "\<u^\>", "\\^u", searchOptionS )
LReplace( "\<U^\>", "\\^U", searchOptionS )
LReplace( '\<u"\>', '\\"u', searchOptionS )
LReplace( '\<U"\>', '\\"U', searchOptionS )
LReplace( "\<\?\>", "?`", searchOptionS )
LReplace( "\<!\>", "!`", searchOptionS )
LReplace( "\<lt\>", "$<$", searchOptionS )
LReplace( "\<gt\>", "$>$", searchOptionS )
END
--- cut here: end ----------------------------------------------------
5. -Run this macro on the input SubML file
--- cut here: begin --------------------------------------------------
<book>
<chapter>
<chaptertitle>ABOUT THIS BOOK</chaptertitle>
<section>
<sectiontitle>Purpose</sectiontitle>
<para>
They say that necessity is the mother of invention. At least in the
case of this book, that adage is true. As an industrial electronics
instructor, I was forced to use a sub-standard textbook during my
first year of teaching. My students were daily frustrated with the
many typographical errors and obscure explanations in this book,
having spent much time at home struggling to comprehend the material
within. Worse yet were the many incorrect answers in the back of the
book to selected problems. Adding insult to injury was the $100+
price.
</para>
</section>
<section>
<sectiontitle>The use of SPICE</sectiontitle>
<para>
One of the best ways to learn how things work is to follow the
inductive approach: to observe specific instances of things working
and derive general conclusions from those observations. In science
education, labwork is the traditionally accepted venue for this type
of learning, although in many cases labs are designed by educators to
reinforce principles previously learned through lecture or textbook
reading, rather than to allow the student to learn on their own
through a truly exploratory process.
</para>
<para>
Having taught myself most of the electronics that I know, I appreciate
the sense of frustration students may have in teaching themselves from
books. Although electronic components are typically inexpensive, not
everyone has the means or opportunity to set up a laboratory in their
own homes, and when things go wrong there is no one to ask for help.
Most textbooks seem to approach the task of education from a deductive
perspective: tell the student how things are supposed to work, then
apply those principles to specific instances that the student may or
may not be able to explore by themselves. The inductive approach, as
useful as it is, is hard to find in the pages of a book.
</para>
<para>
However, textbooks do not have to be this way. I discovered this when
I started to learn a computer program called SPICE. It is a text-
based piece of software intended to model circuits and provide
analyses of voltage, current, frequency, etc. Although nothing is
quite as good as building real circuits to gain knowledge in
electronics, computer simulation is an excellent alternative. In
learning how to use this powerful tool, I made a discovery: SPICE
could be used within a textbook to present circuit simulations to
allow students to "observe" the phenomena for themselves. This way,
the readers could learn the concepts inductively (by interpreting
SPICE's output) as well as deductively (by interpreting my
explanations). Furthermore, in seeing SPICE used over and over again,
they should be able to understand how to use it themselves, providing
a perfectly safe means of experimentation on their own computers with
circuit simulations of their own design.
</para>
</section>
<section>
<sectiontitle>Acknowledgements</sectiontitle>
<itemize>
<item><italic>GNU/Linux</italic> Operating System -- Linus Torvalds,
Richard Stallman, and a host of others too numerous to mention.</item>
<item><italic>Vim</italic> text editor -- Bram Moolenaar and
others.</item>
<item><italic>Xcircuit</italic> drafting program -- Tim Edwards.</item>
<item><italic>SPICE</italic> circuit simulation program -- too many
contributors to mention.</item>
<item><italic>Nutmeg</italic> post-processor program for SPICE --
Wayne Christopher.</item>
<item><TeX> text processing system -- Donald Knuth and others.</item>
<item><italic>Texinfo</italic> document formatting system -- Free
Software Foundation.</item>
<item><LaTeX> document formatting system -- Leslie Lamport and
others.</item>
<item><italic>Gimp</italic> image manipulation program -- too many
contributors to mention.</item>
<item><italic>Winscope</italic> signal analysis software -- Dr.
Constantin Zeldovich. (Free for personal and academic use.)</item>
</itemize>
<quotation>
<para>
<italic>"A candle loses nothing of its light when lighting
another"</italic>
</para>
<para>
<bold>Kahlil Gibran</bold>
</para>
</quotation>
<para>
<url>http://www.faqts.com</url>
</para>
</section>
</chapter>
<pagebreak>
</book>
--- cut here: end ----------------------------------------------------
6. -This will generate this LaTex output file
(note: you might have to install the hyperref package
in you LaTeX)
--- cut here: begin --------------------------------------------------
\documentclass{report} \usepackage[dvips, bookmarks,
colorlinks=true, plainpages = false, citecolor = green, urlcolor =
blue, filecolor = blue]{hyperref} \usepackage{makeidx} \usepackage
[dvips]{graphics} \makeindex \begin{document}
\chapter{ABOUT THIS BOOK}
\section{Purpose}
\
They say that necessity is the mother of invention. At least in the
case of this book, that adage is true. As an industrial electronics
instructor, I was forced to use a sub-standard textbook during my
first year of teaching. My students were daily frustrated with the
many typographical errors and obscure explanations in this book,
having spent much time at home struggling to comprehend the material
within. Worse yet were the many incorrect answers in the back of the
book to selected problems. Adding insult to injury was the \$100+
price.
\
\section{The use of SPICE}
\
One of the best ways to learn how things work is to follow the
inductive approach: to observe specific instances of things working
and derive general conclusions from those observations. In science
education, labwork is the traditionally accepted venue for this type
of learning, although in many cases labs are designed by educators to
reinforce principles previously learned through lecture or textbook
reading, rather than to allow the student to learn on their own
through a truly exploratory process.
\
\
Having taught myself most of the electronics that I know, I appreciate
the sense of frustration students may have in teaching themselves from
books. Although electronic components are typically inexpensive, not
everyone has the means or opportunity to set up a laboratory in their
own homes, and when things go wrong there is no one to ask for help.
Most textbooks seem to approach the task of education from a deductive
perspective: tell the student how things are supposed to work, then
apply those principles to specific instances that the student may or
may not be able to explore by themselves. The inductive approach, as
useful as it is, is hard to find in the pages of a book.
\
\
However, textbooks do not have to be this way. I discovered this when
I started to learn a computer program called SPICE. It is a text-
based piece of software intended to model circuits and provide
analyses of voltage, current, frequency, etc. Although nothing is
quite as good as building real circuits to gain knowledge in
electronics, computer simulation is an excellent alternative. In
learning how to use this powerful tool, I made a discovery: SPICE
could be used within a textbook to present circuit simulations to
allow students to "observe" the phenomena for themselves. This way,
the readers could learn the concepts inductively (by interpreting
SPICE's output) as well as deductively (by interpreting my
explanations). Furthermore, in seeing SPICE used over and over again,
they should be able to understand how to use it themselves, providing
a perfectly safe means of experimentation on their own computers with
circuit simulations of their own design.
\
\section{Acknowledgements}
\begin{itemize}
\item \textit{GNU/Linux} Operating System -- Linus Torvalds, Richard
Stallman, and a host of others too numerous to mention.
\item \textit{Vim} text editor -- Bram Moolenaar and others.
\item \textit{Xcircuit} drafting program -- Tim Edwards.
\item \textit{SPICE} circuit simulation program -- too many
contributors to mention.
\item \textit{Nutmeg} post-processor program for SPICE -- Wayne
Christopher.
\item \TeX{} text processing system -- Donald Knuth and others.
\item \textit{Texinfo} document formatting system -- Free Software
Foundation.
\item \LaTeX{} document formatting system -- Leslie Lamport and others.
\item \textit{Gimp} image manipulation program -- too many
contributors to mention.
\item \textit{Winscope} signal analysis software -- Dr. Constantin
Zeldovich. (Free for personal and academic use.)
\end{itemize}
\begin{quotation}
\
\textit{"A candle loses nothing of its light when lighting another"}
\
\
\textbf{Kahlil Gibran}
\
\end{quotation}
\
\url{http://www.faqts.com}
\
\vfil \eject
\printindex \end{document} \end{report}
--- cut here: end ----------------------------------------------------
7. To see the URL as clickable, you will have to convert it to PDF.
1. -I used PCTex for this
8. You can see the result PDF file at
http://www.knud.info/FaqtsSubmlUrl.htm
1. Note:
It is very important that you do
not include spaces around your URL,
otherwise your URL will be interpreted
as a relative URL
(=relative to the site where it is currently stored)
---
e.g.
<URL> http://www.faqts.com </URL>
---
is interpreted like
http://www.knud.info%20/http://www.faqts.com%20
---
---
2. Thus you should not include spaces around
your URL
---
e.g.
<URL>http://www.faqts.com</URL>
---
is now correctly interpreted like
http://www.faqts.com
---
---
Tested successfully on Microsoft Windows XP Professional, running
PCTeX v5.1
---
---
Internet: see also:
---
TSE: Subml: Links: Overview: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/34894/fid/1765
----------------------------------------------------------------------