0

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:

  1. 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 \linkdest as if I use only one hypertarget the target is displaced in its position in the page.
  2. 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.

  • 2
    Well I can't look during the next week but your contentsline definition looks unneeded. – Ulrike Fischer Mar 19 '23 at 02:01
  • @UlrikeFischer: you are right I've tested now, it compile with contentsline. I've redefined as mycontentsline since in my full code can't get rid of a "missing }" warning, but prabably was not related to this part of the code. – Alexander Beerhoff Mar 19 '23 at 15:10
  • I tested the MWE with \contentsline instead of \mycontentsline but links don't work, so I just make it clear in the post. – Alexander Beerhoff Mar 20 '23 at 17:17

0 Answers0