TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want the print version of a document have links or URLs written out but the online version have the abbreviated tag/name. So the switch, set at the beginning, will choose between two alternatives, e.g.

share|improve this question
up vote 2 down vote accepted

It should be as simple as: (the macro is taken almost verbatim from bidi package)

  \catcode`\$=6 %
  \catcode`\#=12 %
This is \href{http://google.com}{Google}
share|improve this answer

Besides the links, there might be other things you need to set for screen viewing or printing, so you will need some sort of a switch. This would normally go in the preamble of the document as shown below.

I will use the ifthen package for the boolean as people still find its syntax useful:


You then set the various parameters as:


What you normally need to take care of, is margins, link colors and the typing of urls. For the links you can define a command as:


The following MWE illustrates the technique and some typical values for settings:



%% Initialize values to ForPrinting=false
\newcommand{\Margins}{hmarginratio=1:1}     % Symmetric margins
\newcommand{\HLinkColor}{blue}              % Hyperlink color
%% Re-set if ForPrinting=true
  \renewcommand{\Margins}{hmarginratio=2:3} % Asymmetric margins
  \renewcommand{\HLinkColor}{black}         % Hyperlink color

  pdftitle={Project Name},
  pdfauthor={Your name},
  pdfstartview=Fit,    % default value
  pdfstartpage=1,      % default value
  pdfpagemode=UseNone, % default value
  bookmarks=true,      % default value
  linktocpage=false,   % default value
share|improve this answer
I guess usepackage{hyperef} is to be added to the MWE. – Maesumi May 30 '12 at 21:10
Is the switch to be turned by \setboolean{ForPrinting}{false} ? I get same output in both cases. – Maesumi May 30 '12 at 21:15
@Maesumi The hyperref is added in the MWE above near the linkcolor.You need to setboolean{ForPrinting}{true}, uncomment the line. – Yiannis Lazarides May 30 '12 at 21:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.