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.


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}

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
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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