1

I know that you can highlight text inside a section like this : \section{\hl{text}}. But in my case, I have text in italic inside my section, and it won't work.

Here's the code I tried : \subsubsection*{\hl{Author, \textit{Book} (date)}}. enter code here

Any idea?

Here's my entire code :

% Template

%Format \documentclass[10pt]{report} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[a4paper,portrait,hmargin=1.5cm,vmargin={2.5cm,2.1cm},headheight=12.5pt]{geometry} \usepackage[french]{babel}

%Chapitres, sections... \renewcommand{\chaptername}{Chapitre} \renewcommand{\partname}{Partie} \renewcommand{\thesection}{\Roman{section}} % \arabic{} ou \Alph{} ou \Roman{} \renewcommand{\thesubsection}{\Alph{subsection}}

\begin{document} \part{Europe} \part{Latine America} \section{Identity and Culture} \subsubsection{Author, \textit{Book's title} (1981)} %this one works \subsection{\hl{author, \textit{Book's title} (1981)}} %this one won't some text

\end{document}

  • Could you include more code please, starting with \documentclass and ending with \end{document}? It is difficult to help with limited information, help us help you (: – JamesT Feb 10 '23 at 10:16
  • @JamesT Sure thing! Thanks :) – KeebMaster Feb 10 '23 at 10:23
  • \subsubsection*Author, \textit{Book's title} (1981)} is missing an opening { after * – JamesT Feb 10 '23 at 10:23
  • @JamesT How yeah, it's a typo. The error is not in the original document. – KeebMaster Feb 10 '23 at 10:24
  • 1
    really you should post a document so people can test, but make it minimal,only include packages required to show the problem to help people trace the code You have posted a lot of code but it doesn't include an example of your problem – David Carlisle Feb 10 '23 at 10:27
  • I sincerely apologize for the inconvenient and thank your for your patience. I changed the code a little. – KeebMaster Feb 10 '23 at 10:32
  • 4
  • @cabohah No. Unline the the person who posted this question, I knew where to put the command, but had codes and packages problems. – KeebMaster Feb 10 '23 at 10:46
  • @KeebMaster The answer not only shows the usage of the command, but also the needed packages. So I still think, this is a duplicate. – cabohah Feb 10 '23 at 11:42
  • 3
    As for the current version of your question, I don't quite get the problem. You are not loading the soul package that defines the \hl macro, so you should add this to your MWE. But having added this package, your code compiles just fine. Maybe you need to explain better what you want to achieve. At least, I don't think that there should be a problem with using italics. – Jasper Habicht Feb 10 '23 at 11:47

1 Answers1

1
\documentclass[10pt]{report}

\usepackage{soul}   % <------- Added: https://tex.stackexchange.com/a/114909/273733
\usepackage{xcolor} % <------- Added
\usepackage[colorlinks=true,breaklinks=false,linkcolor=black,urlcolor=black,pdfauthor={Me}]{hyperref}
%\usepackage{hyperref}

\title{\textbf{\Huge{Authors}}}
\date{2022}
\author{Me}

\begin{document}
\part{Europe}
\part{Latine America}
\chapter{Testing}
\section{Identity and Culture}
\subsubsection*{\hl{Author, \textit{Book's title} (1981)}}
some text
\end{document}

enter image description here

As an aside, your code in the question could not compile (as I mentioned in the comments) and was too long, for example, the packages needed to use \hl were not present.

You are loading hyperref twice which can cause issues, hyperref should be loaded only once and last (except for packages such as cleveref, glossaries etc). Hopefully this does as you seek.

JamesT
  • 3,169
  • It does work! Thanks you very much :) I thought soul and xcolor were loaded, but it seems I loaded them along with some other packages randomly, and hyperref was indeed intefering. Thanks for the tips! – KeebMaster Feb 10 '23 at 10:35
  • I still had problems. I figured out the problem didn't stem from \hl or \it or any other packages. The thing is, the title of the book had the character "é" (common in the language I'm writing in), and \subsection doesn't seem to handle "é" or "è". I'm sorry I didn't figure it out myself. But I greatly appreciated your tips on my code. – KeebMaster Feb 10 '23 at 10:51
  • For some reasons, @JamesT, I cannot use "é" in a \section, but have to use 'e, any idea why? – KeebMaster Feb 10 '23 at 10:55
  • @KeebMaster I will look into it now, it will be a font package or font issue. I would look into using lualatex or xelatex if you are writing in a language other then English as you said, the code compiles when I use lualatex. Is using lualatex possible with your code? It doesn't change much, pdflatex and lualatex behave similarly so not much change is needed – JamesT Feb 10 '23 at 11:11
  • T. No :/ I got this message : "inputenc package ignore with utf8 based engines" and it won't compile. – KeebMaster Feb 10 '23 at 11:21
  • @KeebMaster how are you compiling your document? lualatex compiles on my system and on Overleaf. Delete the \usepackage{inputenc} and try again, it should compile. Let me know what happens – JamesT Feb 10 '23 at 11:24
  • 1
    I usually use "fast compile" (That's how it's called in French) using Texmaker. I had to use luainputenc for it to work, but it now works wonder!

    I didn't know about lualatex before.

    Thank you very much!

    – KeebMaster Feb 10 '23 at 11:31
  • 1
    No worries, glad it worked, lualatex is a little slower but it is really good! – JamesT Feb 10 '23 at 11:36