Three suggestions:
See Why is \[ … \]
preferable to $$
?
Define a macro/command if you're using something multiple times. It promotes consistency and would make your life much easier if you decide to change things later on, even just a little bit. For example, \itemmul{<mat1>}{<mat2>}
. As reference, see Consistent typography.
You can modify the spacing around a relation/operator to your liking by changing it into an ordinal symbol first, and then specifying the kerning using \mkern
. Ordinals are obtained by wrapping the relation/operator in braces, like {\cdot}
or using \mathord{\cdot}
. Math kerning is specified in mu
s (or m
ath u
nits).
Using the above suggestions, here's a take on your spacing:
\documentclass{article}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\newcommand{\itemmul}[2]{% \itemmul{<mat1>}{<mat2>}
\widehat{#1}\mkern1mu{\cdot}\mkern1mu\widehat{#2}% itemwise-multiplication
}
\begin{document}
\[
(\itemmul{w}{S})^{\intercal}\widetilde{H}(\itemmul{w}{S})
\]
\end{document}
Updated Solution:
Instead of using different macros (as in the earlier version below), I think it makes more sense to have a single macro that is flexible enough to do what you want. Here I have defined the macro \MyItem[<left>][<right>]{<content>}
, which accepts two optional parameters:
- If none of the optional parameters are specified, the enumerated item is printed as
2.
- If both optional parameters are specified, they are treated as being the left and right delimiters to be placed around the enumerated item. So the enumerated item will be typeset as
<left>2<right>
.
- If only one of the optional parameters is provided then that is used as as itemized label and the enumeration is paused.
Here are some of the possibilities:
Further Enhancements:
- If you have more than one of these in your document you will need to have a method to reset the counter use by the enumeration, or use a different series name.
Code:
\documentclass{article}
\usepackage{enumitem}
\usepackage{xparse}
\NewDocumentCommand{\MyItem}{o o m}{%
% If #2, second optional second parameter, is provided then
% use an enumerated item with #1 = left, #2 = right
% else if the
% use #1, first optional parameter is provided
% use #1 as the itemize label
% else use enumerated number
%
% #3 = content
%
\IfNoValueTF{#2}{%
\IfNoValueTF{#1}{%
\begin{enumerate}[series=MyItem,resume=*,label={\arabic*.}]%
\item #3%
\end{enumerate}%
}{%
\begin{itemize}[label={#1}]%
\item #3%
\end{itemize}%
}%
}{%
\begin{enumerate}[series=MyItem,resume=*,label={#1\arabic*#2}]%
\item #3%
\end{enumerate}%
}%
}%
\begin{document}
\MyItem{no parameter}
\MyItem[(][)]{use round braces}
\MyItem[{[}][{]}]{use square braces}
\MyItem[$\langle$][$\rangle$]{use angle braces}
\MyItem{no parameter - numbering continues}
\MyItem[{[}][$\rangle$]{use mixed braces}
\MyItem[$-$]{custom symbol}
\MyItem[][)]{no left bracket}
\MyItem[][]{no symbol for left and right}
\MyItem[$\ast$][]{no symbol for right}
\MyItem[$\circ$]{another custom symbol!}
\MyItem{no parameter - numbering continues}
\end{document}
If I understand you correctly this should do what you want. It uses the resume
feature available with the enumitem
package.
So, \Foo{poor Yorick!}
uses ()
with the current enumerate
number to provide the label. But it also accepts an optional first parameter in where you can provide your own label to use (in which case the itemize
environment is used with the provided label so as not increment the enumerate
counter. Similarly for \Bar{}
but that uses the []
for the enumerate label by default.
When the optional parameter is provided to either of the two macros, \Foo
and \Bar
behave identically.
Further Enhancements:
- Use more meaningful names for
\Foo
, and \Bar
.
Code:
\documentclass{article}
\usepackage{enumitem}
\usepackage{xparse}
\NewDocumentCommand{\Foo}{o m}{%
\IfNoValueTF{#1}{%
\begin{enumerate}[series=Questions,resume=*,label={(\arabic*)}]%
\item #2%
\end{enumerate}%
}{%
\begin{itemize}[label={#1}]%
\item #2%
\end{itemize}%
}%
}%
\NewDocumentCommand{\Bar}{o m}{%
\IfNoValueTF{#1}{%
\begin{enumerate}[series=Questions,resume=*,label={[\arabic*]}]%
\item #2%
\end{enumerate}%
}{%
\begin{itemize}[label={#1}]%
\item #2%
\end{itemize}%
}%
}%
\begin{document}
\Foo{poor Yorick!}
\Foo[$+$]{poor Yorick!}
\Bar{Joelle}
\Bar[$-$]{Joelle}
\Foo[$\circ$]{poor Yorick!}
\Foo{poor Yorick!}
\end{document}
\end{document}
Best Answer
I'd be tempted to use a sequence of
itemize
andenumerate
environment, using theenumitem
package to help with formattingIn the code below I've used the
resume
feature provided by theenumitem
package to help keep the numbering of theenumerate
environment without having to hardcode any of the numbers.I've also used the optional argument of the
\item
command, which can be used, for exampleIf you plan to use this a lot though, you could always make this into a
\newcommand