I'm trying to make a toc (named list of todos), list senteces, highlighted with custom command \todo, before series of frames created via allowframebreaks. Hope the MWE tell it better:
\makeatletter%%! TEX root = asd-beamer.tex
\let\@starttocorig\@starttoc
\makeatother%%
\documentclass[t,10pt,xcolor={usenames},fleqn]{beamer}
\usepackage{lipsum}
%% colors
\definecolor{todo}{rgb}{0.75, 0.0, 0.2}
%define \mycontentsline
\makeatletter
\protected\def\Hy@toclinkstart{\hyper@linkstart{link}{\Hy@tocdestname}}
\protected\def\Hy@toclinkend{\hyper@linkend}
\def\mycontentsline#1#2#3#4{%
\begingroup
\Hy@safe@activestrue
\edef\x{\endgroup
\def\noexpand\Hy@tocdestname{#4}%
}\x
\ifx\Hy@tocdestname\ltx@empty
\csname l@#1\endcsname{#2}{#3}%
\else
\ifcase\Hy@linktoc % none
\csname l@#1\endcsname{#2}{#3}%
\or % section
\csname l@#1\endcsname{%
\Hy@toclinkstart{#2}\Hy@toclinkend
}{#3}%
\or % page
\def\Hy@temp{#3}%
\ifx\Hy@temp\ltx@empty
\csname l@#1\endcsname{#2}{#3}%
\else
\csname l@#1\endcsname{{#2}}{%
\Hy@toclinkstart{#3}\Hy@toclinkend
}%
\fi
\else % all
\def\Hy@temp{#3}%
\ifx\Hy@temp\ltx@empty
\csname l@#1\endcsname{%
\Hy@toclinkstart{#2}\Hy@toclinkend
}{}%
\else
\csname l@#1\endcsname{%
\Hy@toclinkstart{#2}\Hy@toclinkend
}{%
\Hy@toclinkstart{#3}\Hy@toclinkend
}%
\fi
\fi
\fi
}
\makeatother
%%%
\makeatletter%%see https://tex.stackexchange.com/questions/411987/how-to-fix-hypertargets-directing-links-to-the-line-after-the-target-it-looks-l
%\newcommand{\linkdest}[2][][]{\phantomsection\Hy@raisedlink{\hypertarget{#1}{#2}}\label{sec:#1}}
\newcommand{\linkdest}[2][@empty]{%
\hypertarget{@empty}{#1}
\Hy@raisedlink{%1
\hypertarget{#2}{}
}%1
%\phantomsection\label{#2}
}
\makeatother
\newcounter{todokey}%conta i todo totali per auto ref
\newcounter{todosectionlist}% conta i todo prima di keywordlist
\newcommand\todo[2][todo-\thetodokey]{%todo
\addtocounter{todokey}{1}
\noindent{%
\phantomsection% comment out if hyperref is not used
\linkdest[\protect\color{todo}{#2}]{#1}%
}%
\addtocontents{todo-\thetodosectionlist}{\protect\mycontentsline{subsection}{\parbox{0.4\textwidth}{#2}}{}{#1}}
%\addcontentsline{todo-\protect\thetodosectionlist}{subsubsection}{\textbullet\protect\hyperlink{#1}{#2}\protect\hspace{1mm}}%
}
\makeatletter
\newcommand{\listoftodosbasic}{%listoftodos
@starttocorig{todo-\thetodosectionlist}
}
\makeatother
\newcommand\listtodosname{TODO}%listoftodo
\newcommand\listoftodos{%
\addtocounter{todosectionlist}{1}
\listtodosname\phantomsection: \listoftodosbasic}
% Let's get started
\begin{document}
\begin{frame}[allowframebreaks,fragile]{TOC}
\tableofcontents
\end{frame}
\part{A part}%\linkdest{intro}%
\section{Things to do}
\begin{frame}[allowframebreaks,fragile]{List of todos}\linkdest{rl20todo}
\listoftodos
\end{frame}
\begin{frame}[allowframebreaks,fragile]{Lista di todos}
\begin{itemize}
\item\lipsum[1-2]%
\item monday: \todo{monday-todo}%
\lipsum[1-4]%
\item tuesday: \todo{tuesday-todo}%
\lipsum[1-3]%
\item wednesday: \todo{wednesday-todo}%
\lipsum[1-3]%
\item thursday: \todo{thursday-todo}%
\lipsum[1-3]%
\item friday: \todo{friday-todo}%
\lipsum[1-3]%
\item saturday: \todo{saturday-todo}%
\lipsum[1-3]%
\item sunday: \todo{sunday-todo}%
\lipsum[1-3]%
\end{itemize}
\end{frame}
\end{document}
Also need to define \mycontentsline to get rid of some strange problem (I thought to remove macro \mycontentsline to use \mycontentsline, since seems to NOT related to this problem, but then the links doesn't work).
My problems are:
- Links of todo's TOC point one line below: see How to fix hypertargets directing links to the line after the target? It looks like a bug.
The solution I found is to use twice hypertarget inside
\linkdestas if I use only one hypertarget the target is displaced in its position in the page. - Optional: I would like to see if todo's TOC looks better on two columns but seems difficult to me.
Hope not too messy to look into.
Best regards.