%
% This document class style is used with the Ubuntu Manual.
% https://wiki.ubuntu.com/ubuntu-manual/
% https://launchpad.net/ubuntu-manual
%

%
% Idenfification
%

\NeedsTeXFormat{LaTeX2e}[1994/06/01]

\ProvidesClass{ubuntu-manual}[2010/01/12 v0.0.9 Ubuntu manual document class]

\RequirePackage{xkeyval}
\RequirePackage{xifthen}
\RequirePackage{ifpdf}
\IfFileExists{ifxetex.sty}{\RequirePackage{ifxetex}}{\ClassError{ubuntu-manual}{The ifxetex package is missing.\MessageBreak Run the install-pkgs.sh script again}{The ifxetex package is required but is not installed.\MessageBreak Run the install-pkgs.sh script to install it.}}
\RequireXeTeX% XeTeX is required now
%\RequirePackage[utf8]{inputenc}

%
% Declaration of options
%

\newboolean{@ubuntu@debug}
\DeclareOptionX<ubuntu-manual>{debug}{\setboolean{@ubuntu@debug}{true}}

% Language variables and options
\providecommand*{\@ubuntu@script}{Latin}
\providecommand*{\@ubuntu@language}{english}
\providecommand*{\@ubuntu@language@options}{}
\providecommand*{\@ubuntu@language@code}{en}
\providecommand*{\@ubuntu@xindy@language}{}

% Helper macro for defining language variables and options
% #1 paper size
% #2 class option
% #3 polyglossia language
% #4 polyglossia language options
\newcommand*{\@ubuntu@declare@language}[4]{%
  \ExecuteOptionsX<ubuntu-manual>{#1}% paper size
  \ExecuteOptionsX<ubuntu-manual>{#2}% class option for language
  \renewcommand*{\@ubuntu@language}{#3}% polyglossia language
  \renewcommand*{\@ubuntu@language@options}{#4}% polyglossia language options
}

% Current languages
\define@key{ubuntu-manual}{lang}[default]{%
  \ClassInfo{ubuntu-manual}{Specified language is: #1}%
  \renewcommand*{\@ubuntu@language@code}{\detokenize{#1}}%
  \ifthenelse{\equal{#1}{en}}   {\@ubuntu@declare@language{letterpaper}{english}{english}{variant=american}}{}% English (US)
  \ifthenelse{\equal{#1}{en_US}}{\@ubuntu@declare@language{letterpaper}{english}{english}{variant=american}}{}% English (US)
  \ifthenelse{\equal{#1}{af}}   {\@ubuntu@declare@language{a4paper}{afrikaans}{afrikaans}{}}{}% Afrikaans
  \ifthenelse{\equal{#1}{am}}   {\@ubuntu@declare@language{a4paper}{amharic}{amharic}{}}{}% Amharic
  \ifthenelse{\equal{#1}{ar}}   {\@ubuntu@declare@language{a4paper}{arabic}{arabic}{}\PassOptionsToPackage{RTLdocument}{bidi}\PassOptionsToClass{bidi}{tufte-book}}{}% Arabic
  \ifthenelse{\equal{#1}{ast}}  {\@ubuntu@declare@language{a4paper}{asturian}{asturian}{}}{}% Asturian
  \ifthenelse{\equal{#1}{bg}}   {\@ubuntu@declare@language{a4paper}{bulgarian}{bulgarian}{}}{}% Bulgarian
  \ifthenelse{\equal{#1}{bn}}   {\@ubuntu@declare@language{a4paper}{bengali}{bengali}{}}{}% Bengali
  \ifthenelse{\equal{#1}{br}}   {\@ubuntu@declare@language{a4paper}{breton}{breton}{}}{}% Breton
  \ifthenelse{\equal{#1}{cop}}  {\@ubuntu@declare@language{a4paper}{coptic}{coptic}{}}{}% Coptic
  \ifthenelse{\equal{#1}{ca}}   {\@ubuntu@declare@language{a4paper}{catalan}{catalan}{}}{}% Catalan
  \ifthenelse{\equal{#1}{cs}}   {\@ubuntu@declare@language{a4paper}{czech}{czech}{}}{}% Czech
  \ifthenelse{\equal{#1}{cy}}   {\@ubuntu@declare@language{a4paper}{welsh}{welsh}{}}{}% Welsh
  \ifthenelse{\equal{#1}{da}}   {\@ubuntu@declare@language{a4paper}{danish}{danish}{}}{}% Danish
  \ifthenelse{\equal{#1}{de}}   {\@ubuntu@declare@language{a4paper}{german}{german}{}\renewcommand*{\@ubuntu@xindy@language}{german-din}}{}% German
  \ifthenelse{\equal{#1}{dsb}}  {\@ubuntu@declare@language{a4paper}{lsorbian}{lsorbian}{}}{}% Lower Sorbian
  \ifthenelse{\equal{#1}{dv}}   {\@ubuntu@declare@language{a4paper}{divehi}{divehi}{}}{}% Divehi
  \ifthenelse{\equal{#1}{el}}   {\@ubuntu@declare@language{a4paper}{greek}{greek}{}}{}% Greek
  \ifthenelse{\equal{#1}{en_AU}}{\@ubuntu@declare@language{a4paper}{australian}{australian}{}}{}% English (Australian)
  \ifthenelse{\equal{#1}{en_GB}}{\@ubuntu@declare@language{a4paper}{UKenglish}{english}{variant=british}}{}% English (United Kingdom)
  \ifthenelse{\equal{#1}{eo}}   {\@ubuntu@declare@language{a4paper}{esperanto}{esperanto}{}}{}% Esperanto
  \ifthenelse{\equal{#1}{es}}   {\@ubuntu@declare@language{a4paper}{spanish}{spanish}{}\renewcommand*{\@ubuntu@xindy@language}{spanish-modern}}{}% Spanish
  \ifthenelse{\equal{#1}{et}}   {\@ubuntu@declare@language{a4paper}{estonian}{estonian}{}}{}% Estonian
  \ifthenelse{\equal{#1}{eu}}   {\@ubuntu@declare@language{a4paper}{basque}{basque}{}}{}% Basque
  \ifthenelse{\equal{#1}{fi}}   {\@ubuntu@declare@language{a4paper}{finnish}{finnish}{}}{}% Finnish
  \ifthenelse{\equal{#1}{fa}}   {\@ubuntu@declare@language{a4paper}{farsi}{farsi}{}}{}% Persian
  \ifthenelse{\equal{#1}{fr}}   {\@ubuntu@declare@language{a4paper}{french}{french}{}}{}% French
  \ifthenelse{\equal{#1}{ga}}   {\@ubuntu@declare@language{a4paper}{irish}{irish}{}}{}% Irish
  \ifthenelse{\equal{#1}{gd}}   {\@ubuntu@declare@language{a4paper}{scottish}{scottish}{}}{}% Scottish
  \ifthenelse{\equal{#1}{gl}}   {\@ubuntu@declare@language{a4paper}{galician}{galician}{}}{}% Galician
  \ifthenelse{\equal{#1}{grc}}  {\@ubuntu@declare@language{a4paper}{greek}{ancientgreek}{}}{}% Ancient Greek (to 1453)
  \ifthenelse{\equal{#1}{he}}   {\@ubuntu@declare@language{a4paper}{hebrew}{hebrew}{}}{}% Hebrew
  \ifthenelse{\equal{#1}{hi}}   {\@ubuntu@declare@language{a4paper}{hindi}{hindi}{}}{}% Hindi
  \ifthenelse{\equal{#1}{hr}}   {\@ubuntu@declare@language{a4paper}{croatian}{croatian}{}}{}% Croatian
  \ifthenelse{\equal{#1}{hsb}}  {\@ubuntu@declare@language{a4paper}{usorbian}{usorbian}{}}{}% Upper Sorbian
  \ifthenelse{\equal{#1}{hu}}   {\@ubuntu@declare@language{a4paper}{magyar}{magyar}{}}{}% Hungarian
  \ifthenelse{\equal{#1}{ia}}   {\@ubuntu@declare@language{a4paper}{interlingua}{interlingua}{}}{}% Interlingua
  \ifthenelse{\equal{#1}{id}}   {\@ubuntu@declare@language{a4paper}{bahasai}{bahasai}{}}{}% Indonesian
  \ifthenelse{\equal{#1}{is}}   {\@ubuntu@declare@language{a4paper}{icelandic}{icelandic}{}}{}% Icelandic
  \ifthenelse{\equal{#1}{it}}   {\@ubuntu@declare@language{a4paper}{italian}{italian}{}}{}% Italian
  \ifthenelse{\equal{#1}{ja}}   {\@ubuntu@declare@language{a4paper}{japanese}{japanese}{}}{}% Japanese
  \ifthenelse{\equal{#1}{ko}}   {\@ubuntu@declare@language{a4paper}{korean}{korean}{}}{}% Korean
  \ifthenelse{\equal{#1}{la}}   {\@ubuntu@declare@language{a4paper}{latin}{latin}{}}{}% Latin
  \ifthenelse{\equal{#1}{lv}}   {\@ubuntu@declare@language{a4paper}{latvian}{latvian}{}}{}% Latvian
  \ifthenelse{\equal{#1}{lt}}   {\@ubuntu@declare@language{a4paper}{lithuanian}{lithuanian}{}}{}% Lithuanian
  \ifthenelse{\equal{#1}{ml}}   {\@ubuntu@declare@language{a4paper}{malayalam}{malayalam}{}}{}% Malayalam
  \ifthenelse{\equal{#1}{mr}}   {\@ubuntu@declare@language{a4paper}{marathi}{marathi}{}}{}% Marathi
  \ifthenelse{\equal{#1}{ms}}   {\@ubuntu@declare@language{a4paper}{bahasam}{bahasam}{}}{}% Malaysian
  \ifthenelse{\equal{#1}{nb}}   {\@ubuntu@declare@language{a4paper}{norsk}{norsk}{}}{}% Norwegian
  \ifthenelse{\equal{#1}{nn}}   {\@ubuntu@declare@language{a4paper}{nynorsk}{nynorsk}{}}{}% Nynorsk
  \ifthenelse{\equal{#1}{nl}}   {\@ubuntu@declare@language{a4paper}{dutch}{dutch}{}}{}% Dutch
  \ifthenelse{\equal{#1}{oc}}   {\@ubuntu@declare@language{a4paper}{occitan}{occitan}{}}{}% Occitan (post 1500)
  \ifthenelse{\equal{#1}{pl}}   {\@ubuntu@declare@language{a4paper}{polish}{polish}{}}{}% Polish
  \ifthenelse{\equal{#1}{pt_BR}}{\@ubuntu@declare@language{a4paper}{brazil}{brazil}{}}{}% Brazilian Porteguese
  \ifthenelse{\equal{#1}{pt}}   {\@ubuntu@declare@language{a4paper}{portuges}{portuges}{}}{}% Porteguese
  \ifthenelse{\equal{#1}{ro}}   {\@ubuntu@declare@language{a4paper}{romanian}{romanian}{}}{}% Romanian
  \ifthenelse{\equal{#1}{ru}}   {\@ubuntu@declare@language{a4paper}{russian}{russian}{}}{}% Russian
  \ifthenelse{\equal{#1}{sa}}   {\@ubuntu@declare@language{a4paper}{sanskrit}{sanskrit}{}}{}% Sanskrit
  \ifthenelse{\equal{#1}{se}}   {\@ubuntu@declare@language{a4paper}{samin}{samin}{}}{}% Northern Sami
  \ifthenelse{\equal{#1}{sk}}   {\@ubuntu@declare@language{a4paper}{slovak}{slovak}{}}{}% Slovak
  \ifthenelse{\equal{#1}{sl}}   {\@ubuntu@declare@language{a4paper}{slovenian}{slovenian}{}}{}% Slovenian
  \ifthenelse{\equal{#1}{sq}}   {\@ubuntu@declare@language{a4paper}{albanian}{albanian}{}}{}% Albanian
  \ifthenelse{\equal{#1}{sr}}   {\@ubuntu@declare@language{a4paper}{serbian}{serbian}{}}{}% Serbian
  \ifthenelse{\equal{#1}{sv}}   {\@ubuntu@declare@language{a4paper}{swedish}{swedish}{}}{}% Swedish
  \ifthenelse{\equal{#1}{syc}}  {\@ubuntu@declare@language{a4paper}{syriac}{syriac}{}}{}% Syriac
  \ifthenelse{\equal{#1}{ta}}   {\@ubuntu@declare@language{a4paper}{tamil}{tamil}{}}{}% Tamil
  \ifthenelse{\equal{#1}{te}}   {\@ubuntu@declare@language{a4paper}{telugu}{telugu}{}}{}% Telugu
  \ifthenelse{\equal{#1}{th}}   {\@ubuntu@declare@language{a4paper}{thai}{thai}{}}{}% Thai
  \ifthenelse{\equal{#1}{tr}}   {\@ubuntu@declare@language{a4paper}{turkish}{turkish}{}}{}% Turkish
  \ifthenelse{\equal{#1}{uk}}   {\@ubuntu@declare@language{a4paper}{ukrainian}{ukrainian}{}}{}% Ukrainian
  \ifthenelse{\equal{#1}{vi}}   {\@ubuntu@declare@language{a4paper}{vietnamese}{vietnamese}{}}{}% Vietnamese
  \ifthenelse{\equal{#1}{zh_CH}}{\@ubuntu@declare@language{a4paper}{chinese}{chinese}}{}% Chinese
  \ifthenelse{\equal{#1}{zh_CN}}{\@ubuntu@declare@language{a4paper}{chinese}{chinese}{variant=simplified}}{}% Chinese (simplified)
  \ifthenelse{\equal{#1}{zh_TW}}{\@ubuntu@declare@language{a4paper}{chinese}{chinese}{variant=traditional}}{}% Chinese (traditional)

  \ifthenelse{\equal{#1}{default}}{%
    \ClassWarningNoLine{ubuntu-manual}{Invalid option `#1' for lang key.\MessageBreak The language #1 is not supported yet.\MessageBreak Defaulting to US English.\MessageBreak Email the Ubuntu Manual team for help.}%
    \ExecuteOptionsX<ubuntu-manual>{letterpaper}%
    \ExecuteOptionsX<ubuntu-manual>{english}%
    \renewcommand*{\@ubuntu@language}{english}%
    \renewcommand*{\@ubuntu@language@options}{variant=american}%
    \renewcommand*{\@ubuntu@language@code}{en}%
  }

  \ifthenelse{\equal{\@ubuntu@xindy@language}{}}{%
    \let\@ubuntu@xindy@language\@ubuntu@language%
  }{}
}

% Provide ``print'' and ``screen'' options
\newboolean{@ubuntu@print}\setboolean{@ubuntu@print}{false}
\DeclareOptionX<ubuntu-manual>{print}{\setboolean{@ubuntu@print}{true}}
\DeclareOptionX<ubuntu-manual>{screen}{\setboolean{@ubuntu@print}{false}}

% The ubuntu-manual document class has no options of its own, yet.  We just
% pass along any options to the underlying Tufte-LaTeX book class.
\DeclareOptionX*{%
  \PassOptionsToClass{\CurrentOption}{tufte-book}%
}

% Don't use letterspacing from tufte-book class as there's a bug there.
\PassOptionsToClass{nols}{tufte-book}

% Use sans serif margin notes
\PassOptionsToClass{sfsidenotes}{tufte-book}

% Fully-ustified text
%\PassOptionsToClass{justified}{tufte-book}

%
% Execute options
%

\ProcessOptionsX*<ubuntu-manual>\relax

%
% Hyperref options for print/screen versions
%
\ifthenelse{\boolean{@ubuntu@print}}{%
  \PassOptionsToPackage{unicode,hyperindex=false}{hyperref}
}{%
  \PassOptionsToPackage{unicode,hyperindex=false}{hyperref}
}

%
% Load the underlying Tufte-LaTeX book class
%

\LoadClass{tufte-book}

%
% Load packages
%

\RequirePackage{wrapfig}% load before bidi package

\RequirePackage{calc}
\RequirePackage{setspace}
\RequirePackage{xspace}
\RequirePackage{booktabs}

%\RequirePackage{listings}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}% to modify the running heads/feet and page styles
\RequirePackage{makeidx}% to create the index
\RequirePackage{eso-pic}% to insert the cover page
\RequirePackage{paralist}% for fancier enumeration environments
\RequirePackage{comment}% provides comment environment
\RequirePackage{multicol}% for putting text into multiple columns (load before bidi)
\RequirePackage{pifont}% for arrows and other dingbats
\RequirePackage{textcase}% forces text to be upper- or lowercase
\RequirePackage{substr}% provides some substr-like functions
%\RequirePackage{ccicons}% Creative Commons icons
\graphicspath{{.}{graphics}{../graphics}}
\RequirePackage[colorinlistoftodos,disable]{todonotes}% for putting notes in the PDF to be disabled in production PDF

\RequirePackage{polyglossia}% for translations and other languages/scripts
\expandafter\setdefaultlanguage\expandafter[\@ubuntu@language@options]{\@ubuntu@language}%
\setotherlanguage[variant=american]{english}%
\RequirePackage[autostyle=once]{csquotes}% for language-specific quotation marks

% Load the glossaries package *after* the polyglossia package
\RequirePackage[nonumberlist,translate=true,toc,xindy={glsnumbers=false,language=\@ubuntu@xindy@language,codepage=utf8}]{glossaries}% to create a glossary -- must be loaded AFTER hyperref
\renewcommand{\glspostdescription}{}% suppresses full stop after the description in the glossary

% Load the siunitx package after the glossaries package (otherwise glossaries
% will use the translator package [loaded by siunitx] for translating instead of polyglossia)
%\RequirePackage[load=abbr,mode=text,alsoload=binary]{siunitx}% proper spacing and names for units

%\setmainfont[Mapping=tex-text,Numbers=OldStyle,SmallCapsFont={* C}]{Linux Libertine O}
\setmainfont[Mapping=tex-text,Numbers=OldStyle]{Linux Libertine O}
%\setsansfont[Mapping=tex-text,Numbers=OldStyle]{Linux Biolinum O}
\setsansfont[Mapping=tex-text,Numbers=OldStyle,Scale=MatchLowercase]{Ubuntu}
\setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}
%\newfontinstance\scshape[Letters=SmallCaps,Numbers=Uppercase]{Linux Libertine O}
% Set the xindy language for glossaries
%\GlsSetXdyLanguage{\@ubuntu@language}

% A command that prints an interrupting dash.  Varies per language.  (For example, US is ``---'' without spacing, UK is `` -- '' with space.)
\newcommand{\dash}{\unskip\penalty0---\ignorespaces}

\ifthenelse{\boolean{@ubuntu@debug}}{\XeTeXtracingfonts=1}{\XeTeXtracingfonts=0}% log font switching

%\RequirePackage{xmpincl}% XMP for CC licensing% FIXME fails with XeTeX

% Make sure URLs are printed in English
\urlstyle{same} % gets rid of that rubbishy monospaced URL font - humphreybc
\def\do@url@hyp{\do\-}% allow line breaks after hyphens
\def\UrlBigBreaks{\do@url@hyp}% removed colon
\def\UrlNoBreaks{\do\(\do\[\do\{\do\<\do\:}% added colon
\let\@ubuntu@orig@url\url
\renewcommand{\url}[1]{\textenglish{\@ubuntu@orig@url{#1}}}

%
% Format the document style
%

% Redefine the standard font sizes
\renewcommand\normalsize{%
   \@setfontsize\normalsize\@xpt{12}%
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\normalbaselineskip=14pt
\normalsize
\renewcommand\small{%
   \@setfontsize\small\@ixpt{11}%
   \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus2\p@
   \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
               \topsep 4\p@ \@plus2\p@ \@minus2\p@
               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}
\renewcommand\footnotesize{%
   \@setfontsize\footnotesize\@viiipt{9}%
   \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus\p@
   \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
               \topsep 3\p@ \@plus\p@ \@minus\p@
               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}
\renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt}
\renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt}
\renewcommand\large{\@setfontsize\large\@xipt{13}}
\renewcommand\Large{\@setfontsize\Large\@xiipt{14}}
\renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{16}}
\renewcommand\huge{\@setfontsize\huge\@xxpt{24}}
\renewcommand\Huge{\@setfontsize\Huge{24}{30}}


\renewcommand{\@tufte@marginfont}{\normalsize\footnotesize\sffamily\let\smallcaps\MakeTextUppercase}


% Ubuntu color palette
\definecolor{UbuntuOrange}              {HTML}{FF6309}% Ubuntu orange
\definecolor{UbuntuYellow}              {HTML}{FFB515}% Ubuntu yellow
\definecolor{UbuntuRed}                 {HTML}{C90016}% Ubuntu red
\definecolor{OrangeHilight}             {HTML}{EEC73E}% oranges
\definecolor{Orange}                    {HTML}{F0A513}
\definecolor{OrangeBase}                {HTML}{FB8B00}
\definecolor{OrangeShadow}              {HTML}{F44800}
\definecolor{AccentYellowHilight}       {HTML}{FDFF99}% yellows
\definecolor{Yellow}                    {HTML}{FFFF00}
\definecolor{AccentYellowBase}          {HTML}{FDCA01}
\definecolor{AccentYellowShadow}        {HTML}{986601}
\definecolor{AccentOrange}              {HTML}{F44800}% reds
\definecolor{AccentRed}                 {HTML}{FD3301}
\definecolor{AccentRedBase}             {HTML}{D40000}
\definecolor{AccentDeepRed}             {HTML}{980101}
\definecolor{HumanHighlight}            {HTML}{FDD99B}% skin tones
\definecolor{Human}                     {HTML}{D9BB7A}
\definecolor{HumanBase}                 {HTML}{816647}
\definecolor{EnvironmentalShadow}       {HTML}{565248}
\definecolor{EnvironmentalBlueHighlight}{HTML}{AACCEE}% environmental blues
\definecolor{EnvironmentalBlueMedium}   {HTML}{6699CC}
\definecolor{EnvironmentalBlueBase}     {HTML}{336699}
\definecolor{EnvironmentalBlueShadow}   {HTML}{003366}
\definecolor{AccentBlueHighlight}       {HTML}{B3DEFD}% accent blues
\definecolor{AccentBlue}                {HTML}{0197FD}
\definecolor{AccentBlueBase}            {HTML}{0169C9}
\definecolor{AccentBlueShadow}          {HTML}{013397}
\definecolor{AccentGreenHiglight}       {HTML}{CCFF99}% greens
\definecolor{AccentGreen}               {HTML}{98FC66}
\definecolor{AccentGreenBase}           {HTML}{339900}
\definecolor{AccentGreenShadow}         {HTML}{015A01}
\definecolor{UbuntuToner}               {HTML}{002B3D}% toner
\definecolor{AccentMagentHighlight}     {HTML}{FF9BFF}% magentas
\definecolor{AccentMagenta}             {HTML}{FF00FF}
\definecolor{AccentDarkViolet}          {HTML}{6600CC}

%\definecolor{important}{HTML}{980101}% same as accent deep red
%\definecolor{important}{HTML}{DD4814}% Ubuntu orange
%\definecolor{important}{HTML}{82230b}% thorwil test #1
%\definecolor{important}{HTML}{621209}% thorwil test #2
\definecolor{important}{HTML}{a7260e}% thorwil test #3
%\definecolor{UbuntuAubergine}{HTML}{772953}% aubergine (from design.canonical.com heading)
%\definecolor{UbuntuAubergine}{HTML}{1A0512}% aubergine (from https://wiki.ubuntu.com/Brand?action=AttachFile&do=get&target=boot.png)
%\definecolor{UbuntuAubergine}{HTML}{6e154c}% aubergine
%\definecolor{UbuntuAubergine}{HTML}{4c0d34}% aubergine
%\definecolor{UbuntuAubergine}{HTML}{991a68}% aubergine


% Page geometry
\geometry{letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=54\baselineskip,headheight=\baselineskip}

\ifthenelse{\boolean{@tufte@afourpaper}}
  {\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=56\baselineskip,headheight=\baselineskip}}
  {}


\hypersetup{%
  pdfborder = {0 0 0},
  bookmarksdepth = section,
  citecolor = important,
  linkcolor = important,
  urlcolor = important,
  %colorlinks = true,
}%

% If it's for on-screen viewing, use color links; otherwise use black links.
\ifthenelse{\boolean{@ubuntu@print}}{%
  \hypersetup{colorlinks=false,draft}%
}{%
  \hypersetup{colorlinks=true}%
}

% For acronyms
\DeclareRobustCommand{\smallcaps}[1]{{\scshape\MakeTextLowercase{#1}}}
\ExplSyntaxOn
\NewDocumentCommand {\acronym} { m } {
  \fontspec_if_feature:nTF{smcp}{
    {\scshape\MakeTextLowercase{#1}}
  }{
    #1
  }
}
\ExplSyntaxOff

% Format code listings
%\lstset{
  %basicstyle=\normalsize,
  %language=bash,
  %aboveskip=.6em,
  %belowskip=.6em,
  %breaklines=true,
  %identifierstyle=\ttfamily,
  %keywordstyle=\color[rgb]{0,0,1},
  %commentstyle=\color[rgb]{0.133,0.545,0.133},
  %stringstyle=\color[rgb]{0.627,0.126,0.941}
%}

% Enable indexing
\makeindex

% Enable glossaries
\makeglossaries

% Set the running head style to \smallcaps by default
\let\runningheadstyle\smallcaps

% Print the full running heads in the front matter
\renewcommand\frontmatter{%
  \cleardoublepage%
  \@mainmatterfalse%
  \pagenumbering{arabic}%
  %\pagestyle{plain}%
  \fancyhf{}%
  \ifthenelse{\boolean{@tufte@twoside}}%
    {% two-side
      \renewcommand{\chaptermark}[1]{\markboth{##1}{}}%
      \fancyhead[LE]{\thepage\quad\runningheadstyle{\newlinetospace{\plaintitle}}}% book title
      \fancyhead[RO]{\runningheadstyle{\newlinetospace{\leftmark}}\quad\thepage}% chapter title
    }%
    {% one-side
      \fancyhead[RE,RO]{\runningheadstyle{\newlinetospace{\plaintitle}}\quad\thepage}% book title
    }%
}

% Use the \runningheadstyle for running heads in the front and main matter
\renewcommand\mainmatter{%
  \cleardoublepage%
  \@mainmattertrue%
  \fancyhf{}%
  \ifthenelse{\boolean{@tufte@twoside}}%
    {% two-side
      \renewcommand{\chaptermark}[1]{\markboth{##1}{}}%
      \fancyhead[LE]{\thepage\quad\runningheadstyle{\newlinetospace{\plaintitle}}}% book title
      \fancyhead[RO]{\runningheadstyle{\newlinetospace{\leftmark}}\quad\thepage}% chapter title
    }%
    {% one-side
      \fancyhead[RE,RO]{\runningheadstyle{\newlinetospace{\plaintitle}}\quad\thepage}% book title
    }%
}


% Format the chapter and section marks (primarily to remove the \uppercase stuff)
\renewcommand*{\chaptermark}[1]{\markboth{#1}{#1}}%
\renewcommand*{\sectionmark}[1]{}

% Remove \MakeUppercase from TOC marks
\renewcommand\tableofcontents{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \chapter*{\contentsname}\markboth{\contentsname}{}%
  \pdfbookmark[0]{\contentsname}{pdfbookmark:contents}%
  \@starttoc{toc}%
  \if@restonecol\twocolumn\fi
}


% Formatting for main TOC (printed in front matter)
% {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
\newlength{\contentsindent}
\setlength{\contentsindent}{1em}
\titlecontents{part}% FIXME
  [0em] % distance from left margin
  {\vspace{\baselineskip}} % above (global formatting of entry)
  {\contentslabel{\contentsindent}} % before w/label (label = ``II'')
  {} % before w/o label
  {\quad\thecontentspage} % filler + page (leaders and page num)
  [] % after
\titlecontents{chapter}%
  [0em] % distance from left margin
  {\vspace{1\baselineskip}} % above (global formatting of entry)
  {\hspace*{2\contentsindent}\contentslabel{2\contentsindent}} % before w/label (label = ``2'')
  {\hspace*{2\contentsindent}} % before w/o label
  {\quad\thecontentspage} % filler + page (leaders and page num)
  [] % after
\titlecontents{section}% FIXME
  [0em] % distance from left margin
  {\vspace{0\baselineskip}} % above (global formatting of entry)
  {\hspace*{3\contentsindent}\contentslabel{3\contentsindent}} % before w/label (label = ``2.6'')
  {\hspace*{3\contentsindent}} % before w/o label
  {\quad\thecontentspage} % filler + page (leaders and page num)
  [] % after
\titlecontents{subsection}% FIXME
  [0em] % distance from left margin
  {\vspace{0\baselineskip}} % above (global formatting of entry)
  {\hspace*{4\contentsindent}\contentslabel{4\contentsindent}} % before w/label (label = ``2.6.1'')
  {\hspace*{4\contentsindent}} % before w/o label
  {\quad\thecontentspage} % filler + page (leaders and page num)
  [] % after




% Format the chapter headings
\titleformat{\chapter}[block]% command and paragraph shape
  {\bfseries\Huge\sffamily}% format
  {\bfseries\Huge\sffamily\thechapter\quad}% label
  {0mm}% separation
  {}% before
  []% after

\titlespacing*{\chapter}%
  {0pt}% left
  {0pt}% vertical space before title
  {\baselineskip}% separation between title and text
  [0pt]% right

% Format the section headings
\titleformat*{\section}{\sffamily\bfseries\Large}%

% Format the subsection headings
\titleformat*{\subsection}{\sffamily\bfseries\large}%

% Define the \subsubsection command since tufte-book doesn't
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\sffamily\bfseries}}

% Format the subsubsection headings
\titleformat*{\subsubsection}{\sffamily\bfseries\normalsize}%


% The table of contents entries should only go down to \section
\setcounter{tocdepth}{1}

% Only number chapters
\setcounter{secnumdepth}{0}

% Single-space the entire document
\singlespacing

% Inserts the front cover image
\newcommand{\frontcover}{%
  \ifthenelse{\boolean{@ubuntu@print}}{
    \AddToShipoutPicture*{\put(0,0){\includegraphics[width=\paperwidth,height=\paperheight]{titlepage/halftitlepage-\polang.pdf}}}%
      \null\thispagestyle{empty}%
      \cleardoublepage
  }{}%
  \pdfbookmark[0]{\titlepagecaption}{pdfbookmark:title-page}
  \thispagestyle{empty}%
  \IfFileExists{titlepage/titlepage-\polang.pdf}{%
    \AddToShipoutPicture*{\put(0,0){\includegraphics[width=\paperwidth,height=\paperheight]{titlepage/titlepage-\polang.pdf}}}%
  }{%
    \ifthenelse{\boolean{@tufte@afourpaper}}{%
      \ClassWarningNoLine{ubuntu-manual}{No cover page for \@ubuntu@language\space found.\MessageBreak Defaulting to English A4 cover page.}%
      \AddToShipoutPicture*{\put(0,0){\includegraphics[width=\paperwidth,height=\paperheight]{titlepage/titlepage-en.pdf}}}%
    }{%
      \ClassWarningNoLine{ubuntu-manual}{No cover page for \@ubuntu@language\space found.\MessageBreak Defaulting to English letter cover page.}%
      \AddToShipoutPicture*{\put(0,0){\includegraphics[width=\paperwidth,height=\paperheight]{titlepage/titlepage-en_US.pdf}}}%
    }%
  }%
  \null\clearpage%
}

% When cleardoublepage is called, produce a blank (empty) page -- i.e.,
% without headers and footers
\def\cleardoublepage{%
  \clearpage
  \if@twoside%
    \ifodd\c@page\else
      \hbox{}%
      %\vspace*{\fill}
      %\begin{center}
      %  This page intentionally contains only this sentence.
      %\end{center}
      %\vspace{\fill}
      \thispagestyle{empty}%
      \newpage%
      \if@twocolumn\hbox{}\newpage\fi%
    \fi%
  \fi%
}

% Set up the bulleted lists to use gray square bullets
\definecolor{halfgray}{gray}{0.55}% light gray
\newcommand{\bull}{\vrule height 1ex width .8ex depth -.2ex}% square bullet
\newcommand{\graybullet}{\textcolor{halfgray}{\bull}}% gray square bullet
%\setdefaultitem{\graybullet}{}{}{}% set up the four levels of bullets (leave empty to keep default)
%\newcommand{\ubuntubullet}{\smash{\raisebox{0.0ex}{\includegraphics[width=0.666em]{graphics/UbuntuCoF-grey.pdf}}}}
%\newsavebox{\ubuntubulletbox}% using a box for the bullet means the graphic file gets loaded only once -- faster compile times!
%\sbox{\ubuntubulletbox}{\smash{\raisebox{0.0ex}{\includegraphics[width=0.666em]{graphics/UbuntuCoF-grey.pdf}}}}
%\setdefaultitem{\usebox{\ubuntubulletbox}}{}{}{}% set up the four levels of bullets (leave empty to keep default)
\let\smallarrow\relax
\setdefaultitem{\smallarrow}{}{}{}% set up the four levels of bullets (leave empty to keep default)
\setdefaultleftmargin{\parindent}{\parindent}{\parindent}{}{}{}% left margins of lists (leave empty to keep default)


% Set spacing of lists
\RequirePackage{enumitem}
\setlist{noitemsep}% removes vertical spacing between list items
\setlist[description]{style=unboxed}% allow description list item headings to wrap across lines


% Adjust the float parameters so things are a bit more compact
\setcounter{topnumber}{1}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.900}
\renewcommand{\bottomfraction}{0.900}
\renewcommand{\textfraction}{0.050}
\renewcommand{\floatpagefraction}{0.900}

% Disallow orphans and widows
\AtBeginDocument{%
  \widowpenalty=10000%
  \clubpenalty=10000%
  \raggedbottom%
}%

%
% Define useful macros
%

\newcommand{\notecallout}[2][Note]{%
  \marginnote{\textbf{#1:} #2}
}


% An environment for displaying terminal output
\newenvironment{terminal}{%
  \begin{fullwidth}%
  \begin{list}{}{%
    \setlength{\itemindent}{0pt}%
    \setlength{\labelwidth}{0pt}%
    \setlength{\labelsep}{0pt}%
    \setlength{\leftmargin}{12pt}%
    \setlength{\rightmargin}{12pt}%
    \setlength{\listparindent}{0pt}%
    \setlength{\topsep}{0.5\baselineskip}%
    \setlength{\partopsep}{0pt}%
    \setlength{\parsep}{0pt}%
    \setlength{\itemsep}{0pt}%
  }%
    \small\ttfamily\obeylines%
    \item\relax
}{%
  \end{list}%
  \end{fullwidth}%
}

% An environment to set the list of credits (names) in three columns.
\newenvironment{credits}[1][]{%
  \begin{fullwidth}%
  \begin{multicols}{3}[#1]%
    \parskip0pt%
    \parindent0pt%
    \let\item\par%
    \small%
}{%
  \end{multicols}%
  \end{fullwidth}%
}

% An environment to set the list of credits (names) in two columns.
\newenvironment{credits2}[1][]{%
  \begin{fullwidth}%
  \begin{multicols}{2}[#1]%
    \parskip0pt%
    \parindent0pt%
    \let\item\par%
    \small%
}{%
  \end{multicols}%
  \end{fullwidth}%
}

% An environment to set the list of credits (names) in one column.
\newenvironment{credits1}[1][]{%
  \begin{fullwidth}%
    \parskip0pt%
    \parindent0pt%
    \let\item\par%
    #1
}{%
  \end{fullwidth}%
}

% A special environment for the translator credits
\newenvironment{translatorcredits}[1][]{%
  \begin{fullwidth}%
  \begin{multicols}{3}[#1]%
    \parskip0pt%
    \parindent0pt%
    \small%
    \obeylines%
}{%
  \end{multicols}%
  \end{fullwidth}%
}

\newcommand{\name}[1]{#1}      % for the credits section, the name doesn't need an entry in the translation template
\newcommand{\function}[1]{#1}  % for the credits section, only the function need an entry in the translation template

% Macros to distinguish prompts and user input from program output in terminal displays
\newcommand{\prompt}{\texttt{\$}~}
\newcommand{\rootprompt}{\texttt{\#}~}
%\newcommand{\userinput}[1]{{\ttfamily\textcolor{important}{#1}}}% FIXME we'll adjust this formatting later -- red for easy editing at the moment
\newcommand{\userinput}[1]{{\ttfamily\bfseries{#1}}}% FIXME we'll adjust this formatting later -- red for easy editing at the moment
\newcommand{\code}[1]{{\ttfamily#1}}
\newcommand{\filepath}[1]{{\ttfamily#1}}
\newcommand{\package}[1]{{\ttfamily#1}}

% Icons for window controls
\newcommand{\closebutton}{\raisebox{-0.2ex}{\includegraphics[width=0.8em]{graphics/close.png}}}
\newcommand{\maximizebutton}{\raisebox{-0.2ex}{\includegraphics[width=0.8em]{graphics/maximize.png}}}
\newcommand{\minimizebutton}{\raisebox{-0.2ex}{\includegraphics[width=0.8em]{graphics/minimize.png}}}
\newcommand{\unmaximizebutton}{\raisebox{-0.2ex}{\includegraphics[width=0.8em]{graphics/unmaximize.png}}}

% Icons for lenses
\newcommand{\lensicon}[1]{\raisebox{-0.4ex}{\includegraphics[width=1.0em]{graphics/lens-nav-#1.png}}}

% Icons for indicators
\newcommand{\indicatoricon}[1]{\raisebox{-0.4ex}{\includegraphics[width=1.0em]{graphics/indicator-#1.png}}}

% Icons for advanced and warning notices
\newsavebox{\advancedicon}\savebox{\advancedicon}[0.25in][c]{\includegraphics[width=0.25in]{graphics/advanced.pdf}}
\newsavebox{\warningicon}\savebox{\warningicon}[0.25in][c]{\includegraphics[width=0.25in]{graphics/warning.pdf}}

% Macro for advanced usage notes
\newcommand{\advanced}[1]{%
  \smallskip%
  \begin{center}
  \noindent%
  \hspace{\parindent}%
  \begin{minipage}[t]{0.25in}%
    \centering\usebox\advancedicon%
  \end{minipage}%
  \hfill%
  \begin{minipage}[t]{\linewidth-0.30in}%
    \vspace{-\baselineskip}\small\em#1%
  \end{minipage}%
  \hspace{\parindent}%
  \end{center}
  \smallskip\par%
}

% Macro for warning notes
\newcommand{\warning}[1]{%
  \smallskip%
  \begin{center}
  \noindent%
  \hspace{\parindent}%
  \begin{minipage}[t]{0.25in}%
    \centering\usebox\warningicon%
  \end{minipage}%
  \hfill%
  \begin{minipage}[t]{\linewidth-0.30in}%
    \vspace{-\baselineskip}\small\em#1%
  \end{minipage}%
  \hspace{\parindent}%
  \end{center}
  \smallskip\par%
}


% Macro for typesetting menu selection sequences.
% \nav{Menu \then Submenu \then Subsubmenu} would generate text looking like
% ``Menu --> Submenu --> Subsubmenu''.
%\newcommand{\smallarrow}{\raisebox{0.333ex}{\scalebox{0.5}{\ding{228}}}}
\newcommand{\smallarrow}{{\normalfontlatin ‣}}%
%\newcommand{\smallarrow}{\raisebox{0.250ex}{\scalebox{0.5}{\ding{228}}}}

\def\then{\unskip\,\smallarrow\,\allowbreak\ignorespaces}%

\newcommand{\menu}[1]{%
  \begingroup%
    %\def\then{\unskip\ensuremath{\,\rightarrow\,}\ignorespaces}%
    %\def\then{\unskip\,\smallarrow\,\allowbreak\ignorespaces}%
    \textbf{#1}%
  \endgroup%
}

% Macro to format application names and index them
%\newcommand{\application}[2][]{%
%  #2%
%  \ifthenelse{\isempty{#1}}{%
%    \protect\index{#2}%\protect\index{\applicationsheadword!#2}%
%  }{%
%    \protect\index{#1}%\protect\index{\applicationsheadword!#1}%
%  }%
%}
\newcommand{\application}[2][]{#2}

% Macro to format command line programs and index them
%\newcommand{\commandlineapp}[2][]{%
%  {\ttfamily #2}%
%  \ifthenelse{\isempty{#1}}{%
%    \protect\index{#2@\texttt{#2}}%\protect\index{\commandlineappheadword!#2}%
%  }{%
%    \protect\index{#1@\texttt{#1}}%\protect\index{\commandlineappheadword!#1}%
%  }%
%}
\newcommand{\commandlineapp}[2][]{{\ttfamily #2}}

% Add an entry to the index and the main text
\newcommand{\Index}[2][]{%
  #2%
  \ifthenelse{\isempty{#1}}{%
    \protect\index{#2}%
  }{%
    \protect\index{#1}%
  }%
}

% commands for index ranges to avoid '|(' and '|)' in the pot file and to get only one string for start and end of the range
\newcommand{\indexstart}[1]{\index{#1|(}}
\newcommand{\indexend}  [1]{\index{#1|)}}

% Macro to simplify linking to chapters
\newcommand{\chaplink}[1]{%
  % not using \autoref here because I don't want to fix the case of \chapterautorefname for individual languages --godbyk
  \IfBeforeSubStringEmpty{ch:}{#1}{\hyperref[#1]{\@chapapp~}\ref{#1}\hyperref[#1]{: }\nameref{#1}}{\hyperref[ch:#1]{\@chapapp~}\ref{ch:#1}\hyperref[ch:#1]{: }\nameref{ch:#1}}%
}

% Macro to simplify linking to sections
\newcommand{\seclink}[1]{%
  %\IfBeforeSubStringEmpty{sec:}{#1}{\autoref{#1}\hyperref[#1]{: }\nameref{#1}}{\autoref{sec:#1}\hyperref[sec:#1]{: }\nameref{sec:#1}}%
  \IfBeforeSubStringEmpty{sec:}{#1}{\nameref{#1}}{\nameref{sec:#1}}%
}

% Macros to format UI elements
\newcommand{\button}[1]{\textbf{#1}}
\newcommand{\tab}[1]{\textbf{#1}}
\newcommand{\dropdown}[1]{\textbf{#1}}
\newcommand{\checkbox}[1]{\textbf{#1}}
\newcommand{\window}[1]{\enquote{#1}}
\newcommand{\keystroke}[1]{\texttt{#1}}
\newcommand{\radiobutton}[1]{\textbf{#1}}
\newcommand{\textfield}[1]{\textbf{#1}}
\newcommand{\lens}[1]{\textbf{#1}}

% Markup for words that are being defined
\newcommand{\define}[1]{{\itshape #1\/}}

% Aliases to keep things working smoothly
%\let\nav\menu
%\let\menuitem\menu
\newcommand{\nav}[1]{\ClassError{ubuntu-manual}{The \string\nav\space command is obsolete.\MessageBreak Use the \string\menu\space command instead.}{Just replace \string\nav\space with \string\menu\space and you'll be set!}}
\newcommand{\menuitem}[1]{\ClassError{ubuntu-manual}{The \string\menuitem\space command is obsolete.\MessageBreak Use the \string\menu\space command instead.}{Just replace \string\menuitem\space with \string\menu\space and you'll be set!}}

% Screenshot placeholder
\setlength{\fboxsep}{0pt}
\newcommand*{\screenshotslog}{screenshots_missing-\polang.log}
\newwrite\screenshots
\newcommand{\screenshotTODO}[1]{%
  \immediate\write\screenshots{Chapter \thechapter, page \thepage: #1}%
  \par\noindent%
  \begin{figure}
    \fbox{\parbox[c][0.75\linewidth][c]{\linewidth}{\begin{center}\sffamily\bfseries\color{important} M~I~S~S~I~N~G~~~S~C~R~E~E~N~S~H~O~T\par\medskip\footnotesize\normalcolor#1\end{center}}}
    \caption{#1}
  \end{figure}%
  \par%
}
\AtBeginDocument{\immediate\openout\screenshots=\screenshotslog}% open the screenshots.log file
\AtBeginDocument{\immediate\write\screenshots{Missing screenshots:}}% Header entry in screenshots.log file
\AtEndDocument{\immediate\closeout\screenshots}% close the screenshots.log file

\ifthenelse{\boolean{@ubuntu@debug}}{\listfiles}{}

% Pretty ampersand -- may need to be adjusted for non-Linux Libertine fonts
\newcommand{\amp}{{\addfontfeatures{Alternate=1}\itshape \&}\xspace}


% Translated license notes
\newcommand{\@ubuntu@manual@translated@license@notes}{}
\RequirePackage{environ}
\NewEnviron{TranslatedLicenseNotes}{%
  \global\let\@ubuntu@manual@translated@license@notes\BODY%
}
\newcommand{\PrintTranslatedLicenseNotes}{%
  % Only print the translated license notes for the translated editions.
  \ifthenelse{\equal{\polang}{en}\OR\equal{\polang}{en_US}}{%
    % do nothing
  }{%
    \@ubuntu@manual@translated@license@notes
  }%
}


% Command for handling translated licenses
\newcommand{\LoadLicenseFile}{%
  \IfFileExists{backmatter/license-\@ubuntu@language@code.tex}{%
    \input{backmatter/license-\@ubuntu@language@code.tex}%
    \ClassInfo{ubuntu-manual}{Found backmatter/license-\@ubuntu@language@code.tex}%
  }{%
    \input{backmatter/license-en.tex}%
    \ClassInfo{ubuntu-manual}{Didn't find backmatter/license-\@ubuntu@language@code.tex, using backmatter/license-en.tex instead.}%
  }%
}

% The screenshot scale
\newlength{\screenshotscale}
\setlength{\screenshotscale}{1.0pt}

% Measures the width of a graphic and scales it to the max figure* width.
\def\maxscreenshotfile{!Max screenshot filename not set!}%
\newlength{\maxscreenshotwidth}%
\newcommand{\setmaxscreenshot}[1]{%
  \TufteRecalculate% to make sure \@tufte@fullwidth has been calculated
  \gdef\maxscreenshotfile{#1}%
  \settowidth{\maxscreenshotwidth}{\includegraphics{#1}}%
  %\gsetlength{\screenshotscale}{1.0pt * \ratio{\@tufte@fullwidth}{\maxscreenshotwidth}}%
  \gsetlength{\screenshotscale}{1.0pt * \ratio{\textwidth}{\maxscreenshotwidth}}%
}

% Define the screenshot command
%   #1 optional float position specifier
%   #2 screenshot filename (example: xyzzy.png)
%   #3 label (example: xyzzy)
%   #4 caption
\newlength{\screenshotoverflow}% just for debugging
\newsavebox{\screenshotgraphic}
\newcommand{\screenshot}[4][htbp!]{%
  \ifvmode\else\unskip\fi%
  \IfFileExists{screenshots/\@ubuntu@language@code/#2}{%
    \savebox{\screenshotgraphic}{\includegraphics[scale=\strip@pt\screenshotscale]{screenshots/\@ubuntu@language@code/#2}}%
    \ifthenelse{\wd\screenshotgraphic > \maxscreenshotwidth}{%
      \ClassError{ubuntu-manual}{The screenshot `#2' is too large.}{%
        The maximum size of `#2' should not exceed the resolution of `\maxscreenshotfile'.}%
    }{}%
    \setlength{\screenshotoverflow}{\wd\screenshotgraphic-\textwidth}%
    \ifthenelse{\lengthtest{\screenshotoverflow > 0.5pt}}{% allow for some tolerance due to floating-point math
      \ClassInfo{ubuntu-manual}{Screenshot [#2] width is \the\screenshotoverflow\space too wide.}%
      \begin{figure*}[#1]%
        \centering
        \usebox{\screenshotgraphic}%
        \caption{#4}%
        \label{#3}%
      \end{figure*}%
    }{%
      \begin{figure}[#1]%
        \centering
        \usebox{\screenshotgraphic}%
        \caption{#4}%
        \label{#3}%
      \end{figure}%
    }%
  }{%
    \immediate\write\screenshots{Chapter \thechapter, page \thepage: #2}% writing missing screenshots to logfile
    \begin{figure}[#1]%
      \fbox{\parbox[c][0.75\linewidth][c]{\linewidth}{\begin{center}\sffamily\bfseries\color{important} M~I~S~S~I~N~G~~~S~C~R~E~E~N~S~H~O~T\par\medskip\footnotesize\normalcolor#3\par\medskip The file \texttt{screenshots/\@ubuntu@language@code/#2} does not exist!\end{center}}}%
      \caption{#4}%
      \label{#3}%
    \end{figure}%
  }%
  \@esphack%
  \ignorespaces%
}

% Define the \marginscreenshot command
%   #1 optional vertical offset
%   #2 screenshot filename (example: xyzzy.png)
%   #3 label (example: xyzzy)
%   #4 caption
\newcommand{\marginscreenshot}[4][-1.2ex]{%
  \IfFileExists{screenshots/\@ubuntu@language@code/#2}{%
    \begin{marginfigure}[#1]%
      \begin{center}%
        \includegraphics[scale=\strip@pt\screenshotscale]{screenshots/\@ubuntu@language@code/#2}%
      \end{center}%
      \caption{#4}%
      \label{#3}%
    \end{marginfigure}%
  }{%
    \immediate\write\screenshots{Chapter \thechapter, page \thepage: #2}% writing missing screenshots to logfile
    \begin{marginfigure}[#1]%
      \fbox{\parbox[c][0.75\linewidth][c]{\linewidth}{\begin{center}\sffamily\bfseries\color{important} M~I~S~S~I~N~G~~~S~C~R~E~E~N~S~H~O~T\par\medskip\footnotesize\normalcolor#3\par\medskip The file \texttt{screenshots/\@ubuntu@language@code/#2} does not exist!\end{center}}}%
      \caption{#4}%
      \label{#3}%
    \end{marginfigure}%
  }%
}

\newcommand{\gltodo}[1]{%
  \todo[color=LightSkyBlue]{Add #1 to the glossary.}%
}

\newcommand{\hairsp}{\hspace{1pt}}% hair space
\newcommand{\hquad}{\hskip0.5em\relax}% half quad space

% Formats placeholder argument as <placeholder> (in italics)
\DeclareRobustCommand\variable[1]{%
     %\ensuremath\langle
     〈%
     \ifmmode \expandafter \nfss@text \fi
     {%
      \itshape
      \edef\meta@hyphen@restore
        {\hyphenchar\the\font\the\hyphenchar\font}%
      \hyphenchar\font\m@ne
      \language\l@nohyphenation
      #1\/%
      \meta@hyphen@restore
     }〉%
     %\ensuremath\rangle
}

% Revision information that's displayed on the copyright page
\newcommand{\revinfo}[2]{% #1 is the revision number, #2 is the revision date
  \revisionnumbercaption: #1%
  \qquad%
  \revisiondatecaption: #2%
}

% URL for printed book (appears on copyright page)
\newcommand{\printurl}{http://ubuntu-manual.org/buy/gswu1310/\polang}

% Resize the screenshots using the same scale.  To calculate the scale value, we feed in the widest screenshot.
\AtBeginDocument{%
  \setmaxscreenshot{screenshots/fullscreen.png}% TRANSLATORS: Do not translate this line!
}

% Extra hyphenation patterns
\hyphenation{U-bun-tu}

% Copyright page formatting
\newenvironment{copyrightpage}{%
  \clearpage
  \thispagestyle{plain}
  %\includexmp{cc-by-sa}% include XMP CC-BY-SA license
  \null\vfill
  \begingroup
    \setlength{\parindent}{0pt}%
    \setlength{\parskip}{\baselineskip}%
}{%
    \par
    \input{revision}%
  \endgroup
  \clearpage
}

% Colophon page formatting
\newenvironment{colophon}{%
  \thispagestyle{empty}
  \null\vfill
  \pdfbookmark[0]{\colophoncaption}{pdfbookmark:colophon}
  \small
  \parindent0pt
  \parskip\baselineskip
  \acronym{\colophoncaption}
}{}


% CC icons for copyright page
\newcommand{\ccbysa}{{%
  \fontspec{CC Icons}%
  c\,b\,a
}}

% Metadata commands
\newcommand{\credit}[3]{% 1:role 2:version 3:name
  % TODO
}

\newcommand{\version}[2]{% 1:pkgname 2:version
  % TODO
}

\newcommand{\status}[3]{% 1:version 2:date 3:status
  % TODO
}


%
% Hacks and workarounds
%

% This is a workaround for a bug in glossaries v3.05. The package author has
% been notified and is preparing a fix. Once the fix is released and available
% through TeX Live, this workaround may be removed. Details about this bug may
% be found in the following mailing list thread:
% <http://tug.org/pipermail/tex-live/2013-May/033603.html>
%
\def\findrootlanguage{%
  \def\rootlanguagename{\@ubunu@language}%
}


%
% Language-specific overrides
%

% Load language-specific settings
\IfFileExists{um-\@ubuntu@language.clo}{\input{um-\@ubuntu@language.clo}}{}%


%
% Metadata for po4a
%

% po4a: environment lstlisting
% po4a: environment comment
% po4a: command *todo {}
% po4a: command *providecommand {}[][]{}
% po4a: command *ccbysa
% po4a: command *noindent
% po4a: command *frontcover
% po4a: command *listoftodos
% po4a: command *LoadLicenseFile
% po4a: command *printglossaries
% po4a: command *newglossaryentry {}{_}
% po4a: command *screenshot []{}{}{_}
% po4a: command *marginscreenshot []{}{}{_}
% po4a: command *warning {_}
% po4a: command *advanced {_}
% po4a: environment terminal
% po4a: environment credits
% po4a: environment credits1
% po4a: environment credits2
% po4a: environment marginfigure
% po4a: environment margintable
% po4a: environment copyrightpage
% po4a: environment colophon
% po4a: command *credit {}{}{}
% po4a: command *version {}{}
% po4a: command *status {}{}{}
% po4a: command *indexstart {_}
% po4a: command *indexend {_}
% po4a: command *name {}
% po4a: command *function {_}

% Document headings
% po4a: command title {_}
% po4a: command author {_}
% po4a: command part {_}

% Translation environments
% po4a: environment TranslatedLicenseNotes
% po4a: environment translatorcredits

% From Tufte-LaTeX
% po4a: environment fullwidth

%
% All done!
%

\endinput

