0
    \newcounter{entry}[chapter]
    \newcommand{\declarenewentry}[1]{\medskip\noindent\framebox[\textwidth][l]{\qquad Day \theentry : #1}\medskip}

    \newcommand{\newentry}[1]{\addtocounter{entry}{1}\addtocounter{chapter}{1}\phantomsection \addcontentsline{toc}{chapter}{\protect\numberline{\theentry \qquad #1}}\declarenewentry{#1}}

MWE:

\documentclass{book}

\usepackage{bookmark, hyperref}

\newcounter{entry}[chapter]
\newcommand{\declarenewentry}[1]{\medskip\noindent\framebox[\textwidth][l]{\qquad Day \theentry : #1}\medskip}

\newcommand{\newentry}[1]{\addtocounter{entry}{1}\addtocounter{chapter}{1}\phantomsection \addcontentsline{toc}{chapter}{\protect\numberline{\theentry \qquad #1}}\declarenewentry{#1}}

\begin{document}
    \frontmatter
    \mainmatter
        \newentry{August 10, 2021}

            Sample Text
            \section{Sample}

            \newpage
        \newentry{August 11, 2021}

    \backmatter
\end{document}

Now, the problem is that these commands generate a bookmark, but they have no displayed names. I think this is because of \phantomsection. I could probably achieve a better effect by using the sectsty package, but is there a way to name the bookmark?


Edit: Output

enter image description here

As observed, there exists a bookmark with no name. Same goes below the section, as there is a second entry, though it is unnoticeable.

1
  • the problem is that you put the whole content inside the \numberline argument, and that is not shown in the bookmarks. Move the #1 outside the argument. Commented Aug 10, 2021 at 17:45

1 Answer 1

1

My impression is that instead of \newentry you want to use \chapter.

\documentclass{book}

\usepackage{titlesec}
\usepackage{hyperref,bookmark}

\titleformat{\chapter}[block]
 {\normalfont}
 {}
 {0pt}
 {\declarenewentry}
\titlespacing{\chapter}
 {0pt}
 {\medskipamount}
 {\medskipamount}

\newcommand{\declarenewentry}[1]{%
  \framebox[\textwidth][l]{\qquad Day \thechapter: #1}%
}


\begin{document}

\mainmatter

\chapter{August 10, 2021}

Sample Text

\section{Sample}

\chapter{August 11, 2021}

\end{document}

enter image description here

3
  • Is there a way to rename the command as \newentry?
    – soupless
    Commented Aug 11, 2021 at 0:47
  • 1
    @soupless \newcommand{\newentry}{\chapter}
    – egreg
    Commented Aug 11, 2021 at 7:48
  • Thanks, I was going to use letltxmacro for that but.
    – soupless
    Commented Aug 11, 2021 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .