Showing posts with label ams. Show all posts
Showing posts with label ams. Show all posts

Saturday, June 9, 2012

Wrap list around a figure

I often had a need for a way to wrap a list around a figure in the past and hadn't quite found out. Wrapfig and floatflt aren't compatible with lists and break the layout in very bad ways.

Approaches with 2 minipages or tabulars are just wrong, period. There is a new package called cutwin, that you can combine with parshape (or use it without) to coerce your text to do something similar to what ultimately wrapfig should do. I didn't get it to work properly with my ams doc, which is kind of sad. I get the feeling their way of building lists is incompatible with the rest of the latex world :/.

Then i found a solution in some mean way to use minipage. It was still wrong because the type area is so different with ams but after a bit of fiddling with my stuff this works:

\begin{enumerate} 
\item some text
% Rest of old \item
\par
% New \item starts here!
\noindent\begin{minipage}{.88\textwidth}
 \begin{wrapfigure}{r}{.3\textwidth}
   \centering
     \includegraphics[width=.29\textwidth]{pic}
  \end{wrapfigure}
\item[ad d)]
\end{minipage}
\end{enumerate}

Looks really wrong, but does the right thing. Hope this helps someone. I sure would have liked to find this.

A Proof list enumerated by Arrows

Up until recently i used

\begin{enumerate} 
  \item[``$\RightArrow$"] 
  \item[``$\LeftArrow$"] 
\end{enumerate}

or description instead of enumerate which looks even worse. Both don't exactly look right, are cumbersome to type and threw warnings about missing fonts, because latex tried to set the math in bold, so today i sat down and wrote the solution:  


\def\ProofDirection#1{\expandafter\@ProofDirection\csname c@#1\endcsname}
\def\@ProofDirection#1{\ensuremath{\ifcase#1\or\Leftarrow\or\Rightarrow \else\@ctrerr\fi}}
\def\RevProofDirection#1{\expandafter\@RevProofDirection\csname c@#1\endcsname}
\def\@RevProofDirection#1{\ifcase#1\or {$\Rightarrow$}\or {$\Leftarrow$}\else\@ctrerr\fi}

\newcounter{pcounter} 

\newenvironment{myprooflist}[1][]{% 
  
\ifx\relax#1\relax
        \let\@show@count\ProofDirection
     \else
        \let\@show@count\RevProofDirection
     \fi
  \begin{list}{\hss\llap{\textup{``\@show@count{pcounter}''}}}{\usecounter{pcounter}}
  }{
  \end{list}
}


Not only does it work and is cooler, it looks better and is less work to type. Nice!

Thursday, December 22, 2011

ams and enumerate (2nd. time round)

The enumeration problem has been nagging on me overnight and thus investigated further. The solution is simple: the enumerate package is plain incompatible with AMS (probably with anything other than standard latex).

As you can see ams changes a lot of widths including parsep, parindent and leftmargin. The enumerate package also changes leftmargin, unfortunately not relative to the one set but absolute, probably calculated from the standard. So don't use enumerate and AMS! I will define my own list environment from now on which looks better.

Amsthm, lists and enumerate.

Problem:
Amsthm has three theorem styles normal, remark and definition, of which only the normal style is set in italics normally. If you use a list within such a theorem (questionable according to some, necessary to me) then the item labels for these lists are italicized as well which doesn't look good.

The advice to correct this was to manually \textup the label in each item. This of course works normally, but i also employ enumerate. In this case i got a warning "The counter will not be printed.", which is due to the fact, that enumerate will not detect counters that are inside braces.
Solution:
\begin{enumerate}[\upshape i)]
\item...
\end{enumerate}

This finally looks good