Hot answers tagged

20

I took a different approach, not using a list of primes but, rather, using pgfmath to find the primes instead. This was fun. \documentclass{article} \usepackage{pgfmath} \usepackage{enumitem} \newcounter{primecnt} \newcommand{\nextprime}{%\ \loop \stepcounter{primecnt}% \pgfmathsetmacro{\primeTF}{isprime(\theprimecnt)}% ...


19

Here's an enumitem version with a special \AddEnumerateCounter output named \primeenum which can be used label={\primeenum*.} style. Basically, it just applies \ifcase... \or...\fi and lists some prime numbers up to 59, but this can be extended of course. \documentclass{article} \usepackage{enumitem} \makeatletter ...


15

This answer takes Christian's excellent answer (and who deserves the credit for developing the basic structure) and tweaks it to make the input of new primes more streamlined. It uses the \getargsC macro of the readarray package to take a space-separated list and plunk the list into the macros \argi, \argii, \argiii, etc. in romannumeral fashion. This ...


14

Here's a enumitem way and a patch that starts \( after item and ends \) before \item or at the end of the environment, checking with \ifmmode whether we are in math mode or not. Note: \item[...] is not catched here! -- Since the patch is inside the environment group, all other \item definitions in other environments are not changed. It's possible to jump ...


9

If the engine is Unicode aware and a font is used, which contains the glyph for the private Unicode code point: ^^^^e25f See: The ^^ notation in various engines. This is TeX's method to encode non-ASCII characters with ASCII and can also be used inside command tokens. There are also commands to select a character by slot in the current font: LaTeX ...


8

Just for fun, a version that asks Pari-GP to increase the list of primes, using the function nextprime. The final list is written out in the .aux file, so it can be recycled at initialization time. Note that shell escape is needed if the list has to be made larger. Of course, a working Pari-GP installation is needed. \documentclass{article} ...


7

\begin{enumerate}[label=\arabic*.,ref=\arabic*] ... Or add it to the definition of your custom list or whatever.


7

Here's a LuaLaTeX-based solution, which works with both enumerate and itemize environments. It does not actually modify the enumerate and itemize environments, it doesn't modify the \item macro, and it doesn't require the use of a new macro called, say, \mathitem. How does the solution work, then? It takes a preprocessor approach: It sets up a Lua function ...


7

You can create a command like \mathitem that you would use in place of \item when you want that the current item contains only math: \newcommand\mathitem[1]{\item $#1$} Your lists will look like this: \begin{itemize} \mathitem{1+1=2} \mathitem{e^{i\pi}+1=0} \end{itemize}


4

Your problem comes from the fact that graphics are laid on the base line. A solution uses \raisebox: \documentclass{book} \usepackage[demo]{graphicx} \usepackage[shortlabels]{enumitem} \begin{document} \begin{enumerate}[(a)] \item $3,6,9,12, \dots$ \item $3,5,7,9,11, \dots$ \item $2,3,5,7,11,13, \dots$ \item ...


4

Another option is to add \usepackage[export]{adjustbox}, and then add valign=t to the options of \includegraphics. \documentclass{book} \usepackage[demo]{graphicx} \usepackage[shortlabels]{enumitem} \usepackage[export]{adjustbox} \begin{document} \begin{enumerate}[(a)] \item $3,6,9,12, \dots$ \item $3,5,7,9,11, \dots$ \item $2,3,5,7,11,13, ...


4

Without using any extra packages, just redefine \theenumii, \labelenumi and \labelenumii: \documentclass{article} \renewcommand{\theenumii}{\theenumi.\arabic{enumii}} \renewcommand{\labelenumi}{\theenumi)} \renewcommand{\labelenumii}{\theenumii)} \begin{document} \begin{enumerate} \item Firat item \item Second item ...


3

\documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[caption={\textsc{Newton(1,2,5)}}] > 0.0001 > 0.0011 > 0.0111 > 0.1111 > 0.1111 \end{lstlisting} \begin{lstlisting}[caption={\textsc{reciprocal(2,2,5)}}] > 0.0001 > 0.0011 > 0.0111 > 0.1111 > 0.1111 \end{lstlisting} \end{document} An update ...


3

Use the wide option of enumitem. This way the lavbels will be left-aligned along the left margin of text (which is different of left margin of the list): \documentclass{article} \usepackage{enumitem} \usepackage[margin=1.20in,showframe=true]{geometry} \begin{document} \noindent\textbf{\large Problem 1} \begin{enumerate}[wide = 0pt, ...


3

Your minipages should be like \begin{minipage}[b]{\linewidth} Material\par\xdef\tpd{\theprevdepth} \end{minipage} Then the regex match code could be \NewDocumentCommand{\tarassinput}{om} { \tl_set_from_file:Nnn \l_tarass_input_tl { } { #2 } \regex_match:nVTF { \A \c{begin} \cB. minipage \cE. } \l_tarass_input_tl {% true branch: input the minipage ...


3

With version 0.11 of tasks it is possible to say item-format=\ensuremath: \documentclass{article} \usepackage{tasks}[2016/05/03] % v0.11 \begin{document} This is some text. \begin{tasks}[item-format=\ensuremath] \task x + y = z \task e^{i\pi} + 1 = 0 \end{tasks} This is some text. \begin{tasks}[style=enumerate,item-format=\ensuremath] \task x + y = z ...


3

Since the left hand column of the description is in bold letters, you have to calculate the the width based on bold letters. Trying \widthof{\textbf{Connectivity}} solves that problem. As for the insufficient indenting when multiple lines are present, they seem to be about one n space and so I gave a dummy character n or y to the argument of the second ...


3

\documentclass{article} \usepackage{tikz} \renewcommand*{\labelenumi}{\pgfmathparse{int(2^(\theenumi-1))} \pgfmathresult} \begin{document} \begin{enumerate} \item One \item Two \item Three \item more \item more \item more \item more \item more \item more \item more ...


3

Here's a LuaLaTeX-based solution, which works with the enumitem package. It defines an enumerated environment called powertwoenum, in which consecutive items are numbered as 1, 2, 4, 8, 32, etc. Items in a powertwoenum list may be cross-referenced via the usual \label-\ref mechanism. % !TEX TS-program = lualatex \documentclass{article} ...


3

A variant of Christian Hupfer's solution, but fully expandable: \documentclass{article} \usepackage{enumitem} \usepackage{xparse} \ExplSyntaxOn \DeclareExpandableDocumentCommand{\basetwoenum}{m} { \basetwoenum_main:n { #1 } } \cs_new:Nn \basetwoenum_main:n { \exp_args:Nc \basetwoenum_eval:n { c@#1 } } \cs_new:Nn \basetwoenum_eval:n { \fp_eval:n ...


2

An 'awful' mix with enumitem and expl3 features, defining a new counter formater named baseenum -- I've to test with deeper level nesting however. \documentclass{article} \usepackage{enumitem} \usepackage{xparse} \makeatletter \def\basetwoenum#1{\expandafter\@basetwoenum\csname c@#1\endcsname} \ExplSyntaxOn \def\@basetwoenum#1{% \int_set:Nn ...


2

The enumeration is strange here, therefore I use a new list named strangenumerate Since label*= cannot be applied here for the deeper nested levels (it prints a ), there are some other strategies: Make a conditional on the level of nesting and change the label according to this Refer directly to the counter of the current level, i.e. strangenumeratei ...


2

You can create a command that acts like \item[description title]: \newcommand\descitem[1]{\item{\bfseries #1}\\} You can remove the \\ if you don’t want a line break. The style of the title is easy to change. Your enumerate environment will look like: \begin{enumerate} \descitem{Apples} Apples are red, and contain iron. \descitem{Bananas} Bananas ...


2

Instead of juggling with \addtocounter{enumi} etc it's better to use enumitem and it's start=... option. The \getrefnumber{...} macro from refcount provides an aid to get the real 'number' of an reference -- \ref isn't expandable and will fail here. Please note: \getrefnumber{...} will yield anything as equation number here, i.e. something 1.A.5 would be ...


2

I am unsure if this is meant, but the box is before the label: \documentclass[11pt]{article} \usepackage{amssymb} \usepackage{enumitem} \newlist{checklist}{enumerate}{2} \setlist[checklist]{label={$\square$\quad\arabic*.}} \newcommand{\YesNo}{Yes $\square$ \quad No $\square$} \begin{document} Put a check in the box if the statement is mostly true ...


2

The \alph* enumeration labels set a width that's enough for accommodating “m”, the widest letter. You can solve simply the issue by adding align=left: \documentclass{article} \usepackage{enumitem} \usepackage[margin=1.20in,showframe=true]{geometry} \begin{document} \noindent\textbf{\large Problem 1} ...


2

There are a number of things I would do differently, but here is a possible work around for your last environment: \begin{ListExos} \item %\hspace{-20pt}% \begin{minipage}[t]{\linewidth-4cm} %\hspace{20pt}% \raggedright% ne pas commencer par une liste directement \begin{compactenum}%% \item bla ...


2

Instead of an enumerate or itemize environment, consider using a plain array environment. (The horizontal bar in the following screenshot is added only to illustrate the width of the textblock.) \documentclass{article} \begin{document} \hrule\smallskip % just to illustrate width of textblock \noindent \begin{minipage}{0.5\textwidth} \centering ...


2

Too long for a comment: The problem is not related to latex 3 or the input method. It can be shown with a MWE like the following. As one can see the minipage disturbs the spacing. And while one can find with careful analyzing of the code suitable values to correct the spacing, I would avoid such a structure at all costs. It looks unnatural and wrong. ...


1

This is mostly a hack, but it does work well. You could do it with just an environment {questionlist} and then incrementing a counter for the “depth”, that might be easier. \documentclass{scrartcl} \usepackage{etoolbox} \usepackage[shortlabels]{enumitem} \newlist{questionlistA}{enumerate}{1} \setlist[questionlistA]{label=\textup{\arabic*)}} ...



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