jolars / moloch

A LaTeX Beamer theme, forked from the metropolis theme
https://ctan.org/pkg/moloch
Creative Commons Attribution Share Alike 4.0 International
89 stars 5 forks source link

Colorize urls? #32

Closed kflak closed 2 weeks ago

kflak commented 2 weeks ago

Thanks for a great theme!!!

I'm just curious if there is a simple way to give urls in the presentation a different color? To be more specific I'm using beamer through orgmode, and the links render as href elements in the tex document.

samcarter commented 2 weeks ago

Can you show a small test file?

kflak commented 2 weeks ago

This org-mode file:

#+options: toc:nil num:nil
#+title: Miles Davis
#+date: 03 November 2024
#+author: Kenneth Flak
#+email: kennethflak@protonmail.com
#+startup: beamer
#+LaTeX_CLASS: beamer
#+BEAMER_FRAME_LEVEL: 2
#+LATEX_CLASS_OPTIONS: [aspectratio=169]
#+beamer_theme: moloch

** Biography
- Born 1926 in Alton, Illionois, raised in East St. Louis
- Dropped out of Julliard
- Professional debut in 1944
- Died 1991 in Santa Monica, California

that becomes this tex file:

% Created 2024-11-04 Mon 13:34
% Intended LaTeX compiler: pdflatex
\documentclass[aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usetheme{moloch}
\author{Kenneth Flak}
\date{03 November 2024}
\title{Miles Davis}
\hypersetup{
 pdfauthor={Kenneth Flak},
 pdftitle={Miles Davis},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 31.0.50 (Org mode 9.7.11)}, 
 pdflang={English}}
\begin{document}

\maketitle
\begin{frame}[label={sec:org783e025}]{Biography}
\begin{itemize}
\item Born 1926 in Alton, Illionois, raised in East St. Louis
\item Dropped out of Julliard
\item Professional debut in 1944
\item Died 1991 in Santa Monica, California
\end{itemize}
\end{frame}
jolars commented 2 weeks ago

You can colorize urls using hyperref with colorlinks=true and using urlcolor to set the color. Or maybe you had something else in mind?

kflak commented 2 weeks ago

You can colorize urls using hyperref with colorlinks=true and using urlcolor to set the color. Or maybe you had something else in mind?

That sounds very much like what I'm looking for! Not quite sure how to inject that into the orgmode front matter, though... Will sniff around a bit for the docs on that.

samcarter commented 2 weeks ago

You can colorize urls using hyperref with colorlinks=true and using urlcolor to set the color. Or maybe you had something else in mind?

Beamer uses links in a lot of places, e.g. in the toc on section pages etc. I'd rather patch \href.

kflak commented 2 weeks ago

If I add

\usepackage[colorlinks=true, urlink=magenta]{hyperref}

in the front matter of the tex file I get this error:

The package hyperref has already been loaded with options:
  [bookmarks=true,bookmarksopen=true,pdfborder={0 0 0},pdfhighlight={/N},linkbo
rdercolor=[rgb]{0.5,0.5,0.5},implicit=false]
There has now been an attempt to load it with options
  [colorlinks=true, urlink=magenta]
Adding the global options:
  bookmarks=true,bookmarksopen=true,pdfborder={0 0 0},pdfhighlight={/N},linkbor
dercolor=[rgb]{0.5,0.5,0.5},implicit=false,colorlinks=true, urlink=magenta
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.
jolars commented 2 weeks ago

You can colorize urls using hyperref with colorlinks=true and using urlcolor to set the color. Or maybe you had something else in mind?

Beamer uses links in a lot of places, e.g. in the toc on section pages etc. I'd rather patch \href.

Is urlcolor used for anyhting other than urls? Can't you just set the remaining colors to black? (Or maybe there's some options to avoid coloring some of them.)

kflak commented 2 weeks ago

Only using them for links in the presentation. This works:

\documentclass[aspectratio=169, hyperref={colorlinks=true, urlink=magenta}]{beamer}
jolars commented 2 weeks ago

If I add

\usepackage[colorlinks=true, urlink=magenta]{hyperref}

in the front matter of the tex file I get this error:

The package hyperref has already been loaded with options:
  [bookmarks=true,bookmarksopen=true,pdfborder={0 0 0},pdfhighlight={/N},linkbo
rdercolor=[rgb]{0.5,0.5,0.5},implicit=false]
There has now been an attempt to load it with options
  [colorlinks=true, urlink=magenta]
Adding the global options:
  bookmarks=true,bookmarksopen=true,pdfborder={0 0 0},pdfhighlight={/N},linkbor
dercolor=[rgb]{0.5,0.5,0.5},implicit=false,colorlinks=true, urlink=magenta
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.

How are you converting your org-mode text? Pandoc? I think pandoc has a specific hyperref option to set its options.

I think it should be urlcolor, by the way, not urlink.

kflak commented 2 weeks ago

Yes, urlcolor it is, thanks for spotting it! I am using orgmode in emacs, which (I suppose) is calling pandoc behind the scenes. I figured I could set the option like this:

#+BEAMER_FRAME_LEVEL: 2
#+LATEX_CLASS_OPTIONS: [aspectratio=169, hyperref={colorlinks=true, urlcolor=magenta}]
#+beamer_theme: moloch

and it works perfectly for my needs!

samcarter commented 2 weeks ago

Is urlcolor used for anyhting other than urls? Can't you just set the remaining colors to black? (Or maybe there's some options to avoid coloring some of them.)

This way you'll loos the ability to colour elements individually, e.g. to set the colour for toc entries independent from the colour in section pages. Probably not a big deal for moloch, but could be a problem in other themes if the otherwise white title in a footline is suddenly black on dark blue.

jolars commented 2 weeks ago

Is urlcolor used for anyhting other than urls? Can't you just set the remaining colors to black? (Or maybe there's some options to avoid coloring some of them.)

This way you'll loos the ability to colour elements individually, e.g. to set the colour for toc entries independent from the colour in section pages. Probably not a big deal for moloch, but could be a problem in other themes if the otherwise white title in a footline is suddenly black on dark blue.

I see, good point!

I'm closing this issue now because I don't think there is anything that should be done in moloch here.