-
Notifications
You must be signed in to change notification settings - Fork 0
/
fancyitem-doc.tex
133 lines (103 loc) · 3.66 KB
/
fancyitem-doc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
\documentclass[a4paper]{ltxdoc}
\usepackage{doc-preamble}
\usepackage{xparse}
\usepackage[shortlabels]{enumitem}
\usepackage{fancyitem}
% \usepackage{examples2}
\author{Sašo Živanović\footnote{%
e-mail: \href{mailto:[email protected]}{[email protected]};
web: \href{http://spj.ff.uni-lj.si/zivanovic/}{http://spj.ff.uni-lj.si/zivanovic/}}}
\title{fancyitem}
\begin{document}
\maketitle
\begin{abstract}
This package allows the user to redefine the stock |\item|. It also provides
an end-of-item hook.
\end{abstract}
\section{Introduction}
\label{sec:introduction}
The idea of the package is that some specialized environments might be better
off with a specialized |\item| command. For example, within an environment for
linguistic examples, it might be handy to have an |\item| which makes the
judgment mark stick out of the example,
% starts glossing,
and pushes the (parenthesized) language identifier to the right. Like this:
\begin{tcblisting}{example}
\NewDocumentCommand\LinguisticItem{d()s}{% % in the preamble
\IfValueT{#1}{\AtEndItem{\hfill(#1)}}%
\PlainItem
\IfBooleanT{#2}{\mbox{}\llap{*}}%
\ignorespaces
}
\FancyItem[1]{enumerate}{\LinguisticItem}
\begin{enumerate}[(1),labelsep=1em] % in the document
\item(English) This sentence is grammatical.
\item(English)* This sentence ungrammatical is.
\end{enumerate}
\end{tcblisting}
Or perhaps, a listing environment which automatically enables math mode?
\begin{tcblisting}{example}
\newcommand\MathItem{% % in the preamble
\AtEndItem{$}%
\PlainItem$%
}
\FancyItem[1]{itemize}{\MathItem}
\begin{itemize} % in the document
\item (a+1)^2=a^2+2a+1
\item \exists x\colon Ax\wedge Bx
\end{itemize}
\end{tcblisting}
Sky is the limit once you have control over your |\item|.
\section{Usage}
\label{sec:usage}
% todo: depth 0
Load the package:
\begin{tcblisting}{example,listing only}
\usepackage{fancyitem}
\end{tcblisting}
Define an \emph{item macro} (or several) in any way you like, naming it as you
wish:
\begin{tcblisting}{example,listing only}
\def\myitem{\PlainItem\cmd{\myitem}: } % TeX
\newcommand\myitemcommand{\PlainItem\cmd{\myitemcommand}: } % LaTeX
\NewDocumentCommand\MyItemCommand{}{\PlainItem\cmd{\MyItemCommand}: } % LaTeX3
\end{tcblisting}
Associate the item macro to an environment at a certain depth:
\begin{tcblisting}{example,listing only}
\FancyItem[1]{itemize}{\myitem}
\FancyItem[1]{enumerate}{\myitemcommand}
\FancyItem[2]{enumerate}{\MyItemCommand}
\end{tcblisting}
Make a list!
\def\myitem{\PlainItem\cmd{\myitem}: } % TeX
\newcommand\myitemcommand{\PlainItem\cmd{\myitemcommand}: } % LaTeX
\NewDocumentCommand\MyItemCommand{}{\PlainItem\cmd{\MyItemCommand}: } % LaTeX3
\FancyItem[1]{itemize}{\myitem}
\FancyItem[1]{enumerate}{\myitemcommand}
\FancyItem[2]{enumerate}{\MyItemCommand}
\begin{tcblisting}{example}
\begin{enumerate}
\item enumerated list at depth one
\item again
\begin{itemize}
\item first-level itemize
\item again
\end{itemize}
\item
\begin{enumerate}
\item enumerate at depth two
\item again
\end{enumerate}
\end{enumerate}
\end{tcblisting}
As a special treat, the package provides a hook into the end of an item. The
hook is set up by |\AtEndItem|. It makes most sense within an item macro, like
this:
\begin{tcblisting}{example}
\end{tcblisting}
\DocInput{fancyitem.dtx}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "fancyitem.dtx"
%%% End: