1

Basically I wanted to modify the description list so that the first word(s) are underlined and bold

If you compile this file.

\documentclass{article}
\usepackage{soul}
\newenvironment{mydescription}{%
   \renewcommand\descriptionlabel[1]{\hspace{\labelsep}\textbf{\ul{##1}}}
   \begin{description}%
}{%
   \end{description}%
}

\begin{document}

\begin{mydescription}
  \item[First] Test
  \item[Second] Test
\end{mydescription}


\end{document}

The output is okay. But if you compile the following, you see that the environment is not what it is supposed to be. What commands in the preamble are interfering with the compilation and how to solve this issue?

\documentclass[10pt]{article}
\usepackage{soul}
\usepackage[margin=0.75in]{geometry}
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist 
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Lecture 1}
\rhead{Handout 2}

\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\usetikzlibrary{decorations.pathreplacing,calc,graphs,decorations.markings}
\def\annotateEquality#1{ %for the arrow from equality sign
\tikz[overlay]
  \draw[blue,<-] (-1.5ex,1.5ex) -- +(.7,.5) node[right] {#1};
}

\usepackage{comment}
\usepackage{mathtools}

\newcommand{\verteq}{\rotatebox{90}{$\,\neq$}}
\newcommand{\equalto}[2]{\underset{\scriptstyle\overset{\mkern4mu\verteq}{#2}}{#1}}


\usepackage{enumitem,array}
\usepackage{relsize}
\usepackage{amsmath}
\usepackage{amsthm} %for proof 
\newtheorem*{mythm}{Theorem}
\newtheorem*{mydef}{Definition}
\usepackage{centernot} %for `not implies' symbol

\usepackage{amssymb} %for 'therefore' symbol
\usepackage{tikz-cd}% Commutative diagram 
\title{\ul{Expectations in Bivariate Probability Distribution}}
\date{}

\everymath=\expandafter{\the\everymath\displaystyle}

\tikzset{degil/.style={
                decoration={markings,
                mark= at position 0.5 with {
                \node[transform shape] (tempnode) {$\backslash$};
                %\draw[thick] (tempnode.north east) -- (tempnode.south west);
                }
                },
                postaction={decorate}
}
}

\newenvironment{mydescription}{%
   \renewcommand\descriptionlabel[1]{\hspace{\labelsep}\textbf{\ul{##1}}}
   \begin{description}%
}{%
   \end{description}%
}

\begin{document}
\thispagestyle{fancy}
%These define a new itemize environment with 'invisible' bullets
\newenvironment{Myitemize}{%
\renewcommand{\labelitemi}{{}}%
\begin{itemize}[nosep]}{\end{itemize}}
\maketitle 
\thispagestyle{fancy}

 \begin{mydescription}
 \begin{mydescription}
 \item[First] Test
 \item[Second] Test
 \end{mydescription}

\end{document}
  • I'm a bit unsure what you're doing here, but you might try replacing \begin{description} ... \end{description} inside your \newenvironment by \description ... \enddescription, which removes one extra layer of grouping. – yo' Aug 19 '14 at 07:59
  • 1
    I'm also not sure what you are trying to do but it looks like you are just trying to modify the behaviour of the enumerate and description environments. If this is all that you want then the enumitem package gives a very neat way of doing this. –  Aug 19 '14 at 08:07
  • 1
    we don't see that it is not what it is supposed to be unless you tell us what it is supposed to do. – David Carlisle Aug 19 '14 at 08:17
  • you are missing % from ends of lines (which may not be related) \ul{##1}}}%, #1{%for the arrow – David Carlisle Aug 19 '14 at 08:20
  • @tohecz: I'm afraid removing curly brackets didn't work out – Abhimanyu Arora Aug 19 '14 at 09:28
  • @Andrew: Thanks for the suggestion, I'll have a look at it. But I think the problem here is a bit different – Abhimanyu Arora Aug 19 '14 at 09:29
  • @DavidCarlisle: I have modified the question, thanks very much. I'm afraid I did not get your point on the %. Could you please elaborate? – Abhimanyu Arora Aug 19 '14 at 09:30
  • your definition of mydescription is missing a % at the end of the second line and your definition of \annotateEquality has a misplaced comment there should be no space before %for the arrow see http://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines – David Carlisle Aug 19 '14 at 09:52
  • @DavidCarlisle: I'm afraid the solutions as far as % is concerned didn't work. In fact there are errors when I try to provide an option in [...] to the \item in the list... Would you like me to enter chat? – Abhimanyu Arora Aug 19 '14 at 10:08
  • Sorry, but "didn't work" is not quite descriptive. – yo' Aug 19 '14 at 10:25
  • It's a conflict between enumitem and soul. Why do you want to underline the label in the first place? Underlining is considered a bad typographical device. – egreg Aug 19 '14 at 11:15
  • 1
    Ciao @egreg (Enrico): Thanks for pointing it out. I didn't not about it, but it was already there in someoneelse's notes. So I was just reproducing the format in my document :-) – Abhimanyu Arora Aug 19 '14 at 12:17
  • @tohecz: Thanks very much. Basically I meant the (same) situation regarding the errors remains (if you compile the 2nd example above) – Abhimanyu Arora Aug 19 '14 at 12:18

1 Answers1

5

It happens that soul commands cannot be used in the optional argument to \item, when enumitem is loaded: they're quite fragile and don't like to appear in particular places (you get Reconstruction failed besides the \enit@align error).

You could use ulem:

\documentclass[10pt]{article}
\usepackage[normalem]{ulem}
\usepackage{enumitem}

\newenvironment{mydescription}{%
   \renewcommand\descriptionlabel[1]{%
     \hspace{\labelsep}\textbf{\uline{##1}}%
   }%
   \begin{description}%
}{%
   \end{description}%
}

\begin{document}

 \begin{mydescription}
 \item[First] Test
 \item[Second] Test
 \end{mydescription}

\end{document}

but the best thing is forgetting about underlining, which is considered bad practice in fine typography.

enter image description here

egreg
  • 1,121,712