Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Tag Info

34

You can (ab)use \soulregister with the identifier 7. While this command is meant to be used to register font switching commands (with identifier 0 or 1), a look in the implementation part of the documentation reveals that it also accepts other numbers: 9 for accents, 8 for \footnote and, the one that's interesting here, 7 for "\textsuperscript or similar ...

32

It's almost a year later, but as the OP has not yet accepted an answer, I still see my chance :-) In the following, I use the same basic principle as in my other answer, that is, employ listings moredelim=** option to define delimiters, which styles then apply on top of all other formattings, so that the syntax formatting is kept. However, instead of being ...

30

The \ul command from the soul package has troubles with Umlauts -- the \uline command from the ulem package doesn't and therefore seems to be the better option for those not exclusively writing in English.

29

For UTF-8 input, use soulutf8; don't forget fontenc! \documentclass[a4paper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[french]{babel} \usepackage{soulutf8} \usepackage{color} \definecolor{y}{RGB}{245, 255, 189} \sethlcolor{y} \begin{document} \hl{\'e} \hl{é} \end{document} There is no 15pt option for article.

28

Let's make soul work less: \documentclass{article} \usepackage{xparse,soul} \ExplSyntaxOn \NewDocumentCommand{\ulns}{m} { \seq_set_split:Nnn \l_tmpa_seq { ~ } { #1 } \seq_map_inline:Nn \l_tmpa_seq { \ul{##1}~ } \unskip } \ExplSyntaxOff \begin{document} \ulns{The quick brown fox jumped} over the lazy dog. \end{document} Basically, the argument is ...

24

cancel is intended for indicating mathematic cancellation, and consequently only works in math mode; it also strikes out diagnoally. soul and ulem seem pretty similar. One basic semantic difference between them is that ulem per default changes the definition of \emph{...} to underline its argument instead of putting it in italics. This seems to aim at the ...

24

Package soul provides an underlining macro \textul/\ul with the same depth. The following example copies the driver to \textulw/\ulw and leaves the spaces without underline: \documentclass{article} \usepackage{soul} \makeatletter \DeclareRobustCommand*{\textulw}{% \SOUL@ulwsetup \SOUL@ } \newcommand*{\SOUL@ulwsetup}{% \SOUL@setup \let\SOUL@preamble\...

18

The source of the problem is that both xcolor and soul use \dimen@ as a temporary register. And soul uses it at a place where it can't be sure that other commands temper around with this dimen. You can redefine the internal soul command, or you can use \convertcolorsUfalse so that xcolor no longer recalculate color at usage: \documentclass{article} \...

16

The command you defined is fragile and will break in moving arguments. You can either \protect it in moving arguments or, better, declare it robust from the beginning: \documentclass[]{article} \usepackage{soul} \usepackage{color} \DeclareRobustCommand{\hlcyan}[1]{{\sethlcolor{cyan}\hl{#1}}} \begin{document} An example of \hlcyan{highlighted words with ...

15

You can use the package ulem to create new styles. \documentclass[a4paper,12pt]{scrartcl} \usepackage[normalem]{ulem} \usepackage{xcolor} \makeatletter \newcommand\uuuline{\bgroup\markoverwith% {% \textcolor{red}{\rule[-0.5ex]{2pt}{0.4pt}}% \llap{\textcolor{blue}{\rule[-0.7ex]{2pt}{0.4pt}}}% \llap{\textcolor{green}{\rule[-0.9ex]{2pt}{0.4pt}...

15

Using soul package: Looks like the problem is that beamer redefines things. Using the patch from Why is it that coloring in soul in beamer is not visible seems to work: Using tikz package: As Andrew Stacey mentioned int he comments, there is a tikzmark solution as well. Using the code from How to "highlight" text/formulas with tikz?, we get: ...

13

My solution is just to avoid soul package. soul package is very fragile and may be problematic in many situations. I would use more robust ulem package to define a new \hl command: \documentclass{article} \usepackage{xcolor} \usepackage[normalem]{ulem} % use normalem to protect \emph \newcommand\hl{\bgroup\markoverwith {\textcolor{yellow}{\rule[-.5ex]{2pt}...

13

Here's a LuaLaTeX-based solution. It doesn't require loading the soul package. The user macro is called \ulow -- short for "underline only words". With \ulow, all non-letter glyphs, and not just whitespace, are exempt from being underlined. The input is assumed to be UTF8-encoded. (ASCII is a proper subset of UTF8; thus, if your input file is pure ASCII, ...

12

Just put the \cite{hong_groups_2004} in an extra pair of curly brackets ({}), without them, soul will do funny things with the \cite-command: \documentclass{article} \usepackage{color,soul} \begin{document} \hl{A statement {\cite{hong_groups_2004}}} \end{document} You will get some ideas from section 2.1 and 2.2. in the manual. I suggest to use the more ...

11

The problem is in the font used for testing hyphenation. If you add \makeatletter \let\SOUL@tt\relax \newfontface{\SOUL@tt}{FreeMono} \makeatother after loading soul the problem seems to disappear. It probably won't show again characters that are not in the \SOUL@tt font. Full code: \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures = ...

11

For registered commands, soul will split up the string, turning it basically into \ul{first part}\command{\ul{second part}} So if \command produces any text, this will end up outside of the scope of soul's scanner. To solve this you can pre-expand the string before feeding it to soul: \newcommand{\one}[1]{\protected@edef\@tempa{#1}\ul\@tempa} EDIT: ...

10

The soul package scans its argument and doesn't typeset it directly, therefore the content isn't inserted by \input. You need to read the file content manually and feed it to \so (or any other soul macro). This can be done easily using the catchfile package: \documentclass{article} \usepackage{catchfile} \usepackage{soul} \begin{document} \CatchFileDef\...

10

soul scans the text token by token, a process which can easily be messed up when the input stream also contains macros. The package already knows that it should leave font switching commands alone -- therefore \textit works in your case -- but fails with the unknown macro \ApplyStyle. Fortunately, there is an interface to make soul acquainted with new macros:...

10

Another option using curly braces {} around \ref, \cite or \pagerefcommands may be: \documentclass[12pt]{article} \usepackage{soul,color} \begin{document} \st{This is a line containing a citation {\cite{}}.} \hl{This is a line containing a reference {\ref{sec}} on page {\pageref{sec}}.} \so{This reference: {\ref{sec}}, is not letterspaced.} \setcounter{...

8

Let's do an experiment with the following input: \documentclass{article} \usepackage{lmodern} \usepackage{soul} \usepackage{microtype} \begin{document} \scshape\textls{x} % this for not spoiling the test \tracingcommands=1 \wlog{^^J========================^^J} \so{Some spaced out text} \wlog{^^J========================^^J} \textls{Some spaced out text}...

8

If you don't mind to use the ulem package instead of soul, this works: \documentclass{article} \usepackage[normalem]{ulem} \newcommand{\longunderline}[1]{\uline{#1\hfill\mbox{}}} \begin{document} \longunderline{Some long text. Some long text. Some long text. Some long text. Some long text. Some long text.} \longunderline{Some short text.} \...

8

The problem is in the fact that babel-czech makes the hyphen a shorthand character, but soul has no check for an active -; the result is that as many characters at the end are mangled as there are hyphens in the text. Here is a workaround using regexpatch: \documentclass[12pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[czech]...

8

Is this what you intended? \documentclass{article} \usepackage{xcolor} \usepackage{soul} \newcommand{\mathcolorbox}[2]{\colorbox{#1}{$\displaystyle #2$}} \begin{document} For inline math, one can simply do \hl{colored $a=b$ math}. For display math, the following works: $$\mathcolorbox{red}{y=\frac{x^2}{q}}+z$$ \end{document} ...

7

The code from this answer is available as a package http://code.google.com/p/dpctex/source/browse/#svn%2Ftrunk%2Fcjkhl Version with tests for punctuation and \obeylines, the original simpler version as discussed in comments is at the end. It appears (from no knowledge other than the example here) that the CJK punctuation characters have wide side bearings ...

7

As explained by Joseph Wright in his answer, package soul does not support arbitrary commands. The following example shows, how soul can be extended to support \SoulOmitMyLink. It hooks into the code \SOUL@docmd that processes the data of \soulregister. The code is inserted for the case that the second argument of \soulregister is 8. Then the command in the ...

7

\vphantom{\psi} helps. Then the underlining command for i sees the larger descender of \psi, while \psi is not visible: \documentclass{article} \usepackage{amsmath} \usepackage[normalem]{ulem} \begin{document} %underline example \begin{align} m = -\dfrac{3}{2} z_\mathrm{p} \operatorname{Im}\{\underline{\psi}_1^{\angle k} \underline{i\vphantom{\psi}}_1^{\...

7

I'd like to suggest you the \tcbhighmath command from the tcolorbox package; its interaction with empheq will give you the possibility to easily highlight expressions inside the amsmath environments; a little example: The code: \documentclass{article} \usepackage{amsmath} \usepackage{xcolor} \usepackage{soul} \usepackage{empheq} \usepackage[many]{tcolorbox}...

7

If you include the package color or xcolor it will highlight the text background. \documentclass{article} \usepackage{soul} \usepackage{color} \begin{document} \hl{\\$ 10} \end{document} Using \sethlcolor you can set the highlighting color. \documentclass{article} \usepackage{soul} \usepackage{color} \DeclareRobustCommand{\hlgreen}[1]{{\sethlcolor{green}\...

Only top voted, non community-wiki answers of a minimum length are eligible