# How to create a nice case-disinction with no indent and right justified text

How can I create a nice case-distinction of a mixture of text (and potential math-environment), that is numerated (e.g. with i, ii, ...) and has no indent, i.e. all text should be justified on the right side?

\documentclass[15pt, a4paper]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}[i)]
\item Case $\Phi < 0$: Fishing-out problem (most obvious inventions first), $\dot A_i$ decreases , with $A \uparrow$, difficulty of innovation increases with state of the art of an economy
\item Case $\Phi = 0$: no external effects
\item Case $\Phi > 0$: positive external effects predominate - $\dot A_i$ increases with $A \uparrow$ - fundamental research with high spillover effects (differential calculus, electricity, semiconductors)
\end{enumerate}
\end{document}

No text should start before the orange line. And the orange line should be placed in relative position to the longest case-name. What might be the shortest way to achieve this? Thank you

Ok, let me present an older workaround I used: a tabular environment solves the indent problem. But enumeration needs to be done manually and this still doesnt look very nice:

\begin{center}
\begin{tabular}{l p{15cm} }
$1.) \rho > 0$                  & time preference rate \\
$2.) d(j, \omega, t)$   & demanded quantity of goods of quality level $j$ of industry $\omega$ at time $t$ \\
$3.) \sum_{j=0}^\infty$ & all available quality levels $j$ of a consumer good $\omega$ can be consumed at the same time (\underline{in principle}) $\rightarrow$ however: only consumption of those goods with best quality adjusted price \\
\end{tabular}
\end{center}

Now the linespread between cases is too small und the horizontal spaces between the numeration 1.), 2.) ... is also too small. Hope you have another good idea :)

• some time ago, i proposed an answer to How to implement common layouts instead of misusing tabular environments? that suggested (but didn't deliver on) a mechanism for making detection of the length of the longest left-hand element "automatic", but i never actually delivered. if that question and answer would satisfy you, i will undertake an update of that answer. – barbara beeton Apr 9 '15 at 12:40
• @barbarabeeton I have manually brute forced a solution to this in the past when creating exams. I think this would be a very useful package to add to CTAN. – R. Schumacher Apr 9 '15 at 12:46
• @R.Schumacher -- i've used the technique described there a lot, but i've always been too lazy to make it automatic -- the scope has usually been small enough that i knew or could easily determine the widest left-side member. (and i've even used it with dropped-in top-aligned multi-line boxes when running the left-side content to its full width would take too much of the page -- there has to be a limit to the width.) i'll try to form this into a package -- what would be a good name? – barbara beeton Apr 9 '15 at 12:56
• @barbarabeeton And I thought naming children was tough:) My first suggestion would be enumcase. I just check CTAN and a search for this came up empty. – R. Schumacher Apr 9 '15 at 13:07

## Version 2 (+ nested levels)

I continued in these small experiments. I've added an elimination (\def\newenumerate{\def\item{}} and \def\endnewenumerate{}) of the inner environments during the computation part (virtual typesetting). This elimination is done in a local group, so real typesetting is normal and unaffected. This snippet works best when:

• newenumerate environments are used,
• blocks of indented text end with colon.

I enclose an example and a preview of the result.

% *latex mal-enumerate.tex
\documentclass[a4paper]{scrartcl}
\pagestyle{empty}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{enumerate}
\usepackage{environ}

\begin{document}
\let\olditem=\item
\let\oldenumerate=\enumerate
\let\endoldenumerate=\endenumerate
\newdimen\maldimen

\NewEnviron{newenumerate}[1][i)]{%
% measuring a distance
\begingroup
\maldimen=0pt%
\def\newenumerate{\def\item{}}% elimination of inner env.
\def\endnewenumerate{}% elimination of inner env.
\def\item##1: {\setbox0=\hbox{\ ##1: }%
\ifnum\maldimen<\wd0%
\global\maldimen=\wd0%
\fi%
}% redefinition of \item
\setbox1=\hbox{\BODY}%
\endgroup % end of measuring a distance
% an original enumerate
\def\item##1: {\olditem \makebox[0pt][r]{##1: }}%
\oldenumerate[#1]% its begin
\labelsep=\maldimen
\leftskip=\maldimen
\labelwidth=\maldimen
\BODY % a set of \items...
\endoldenumerate% its end
}
%\makeatother

Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before.
\begin{newenumerate}[i)]
\item Case $\Phi < 0$: Fishing-out problem (most obvious inventions first), $\dot A_i$ decreases , with $A \uparrow$, difficulty of innovation increases with state of the art of an economy
\item Case $\Phi = 0$: no external effects
\begin{newenumerate}[a)]
\item A: a no external effects no external effects no external effects no external effects no external effects
\item B: b
\item C: c
\begin{newenumerate}[I)]
\item IA: a no external effects no external effects no external effects no external effects no external effects
\item IB: b
\item IC: c
\end{newenumerate}
\end{newenumerate}
\item Case $\Phi > 0$: positive external effects predominate - $\dot A_i$ increases with $A \uparrow$ - fundamental research with high spillover effects (differential calculus, electricity, semiconductors)
\end{newenumerate}

\begin{newenumerate}[i)]
\item A part: a
\item B part: some text to be displayed  some text to be displayed  some text to be displayed  some text to be displayed
\item C block: c
\end{newenumerate}

\end{document}

## Version 1 (old; first-level environments only)

This is an experiment. I've tried to solve a similar problem today by redefining the itemize environment. This is an adaptation to the enumerate case. It works for me, but only for the first-level environments.

% *latex mal-enumerate.tex
\documentclass[a4paper]{scrartcl}
\pagestyle{empty}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{enumerate}
\usepackage{environ}

\begin{document}
\let\olditem=\item
\let\oldenumerate=\enumerate
\let\endoldenumerate=\endenumerate

\newdimen\maldimen
\NewEnviron{newenumerate}[1][i)]{%
\maldimen=0pt%
\def\item##1: {\setbox0=\hbox{\ ##1: }%
\ifnum\maldimen<\wd0 \global\maldimen=\wd0 \fi%
}%
\setbox2=\vbox{\hbox{\BODY}}%
% an original enumerate
\def\item##1: {\olditem {\makebox[0pt][r]{##1: }}}%
\oldenumerate[#1]% its begin
%\let\oldlabelsep=\labelsep
\labelsep=\maldimen
\leftskip=\maldimen
\labelwidth=\maldimen
%\itemindent=-\maldimen
\BODY % a set of \items...
\endoldenumerate% its end
%\let\item=\olditem
}

Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before. Text before.
\begin{newenumerate}[i)]
\item Case $\Phi < 0$: Fishing-out problem (most obvious inventions first), $\dot A_i$ decreases , with $A \uparrow$, difficulty of innovation increases with state of the art of an economy
\item Case $\Phi = 0$: no external effects
\item Case $\Phi > 0$: positive external effects predominate - $\dot A_i$ increases with $A \uparrow$ - fundamental research with high spillover effects (differential calculus, electricity, semiconductors)
\end{newenumerate}

\begin{enumerate}[i)]
\item A a
\item B b
\item C c
\end{enumerate}

\end{document}

• This is exactly what I wanted to achieve! Looks wonderful - but there is really no easier (native tex) way? – Mac Apr 9 '15 at 13:56
• Generally speaking, the source codes can be complex and huge in size, that's not an issue, we hide it from public in an sty/tex file. But here, at TeX.SX, we need to expose it to be able to compile it, improve it and discuss it. This particular problem of yours is not easy: we need to measure item labels first (store that dimension?), alter environment (or use different one? use several paragraphs for typesetting?) which can be nested. My solution is weak. A tip for you about this area: the layouts package. – Malipivo Apr 9 '15 at 14:23
• No it's not your solution which is weak. That's me :S in a minial working environment I can replicate the result (compile your code). But I can't implement it in my genuine code. It gives me on all other enumerates errors. Do I have to change all of them? – Mac Apr 9 '15 at 15:00
• When I use first-level environments (with colons as delimiter), it works. Could you please edit your question and extend it a bit by adding a portion of your genuide code? – Malipivo Apr 9 '15 at 15:03
• Even if I only use your code in my preamble I get errors and cant compile. But I do use several times a mixture of itemize and enumerates. I dont' know on what aspect to focus (code is about 700 lines long). – Mac Apr 9 '15 at 15:07

Use a box and it is almost close shave with microtype package.

\documentclass[15pt, a4paper]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{enumitem,microtype}
\newlength{\mylen}
\settowidth{\mylen}{Case $\Phi < 0$}
\newcommand{\mybox}[1]{\makebox[\mylen][l]{#1}}
\newlength{\mylenn}
\newlength{\mylenm}
\setlength{\mylenn}{\dimexpr\mylen+\labelwidth+\labelsep\relax}
\setlength{\mylenm}{\dimexpr\mylen+2\labelsep\relax}
\begin{document}

\begin{enumerate}[label= \roman*),leftmargin=\mylenn,
itemindent=-\mylenm]
\item \mybox{Case $\Phi < 0$}: Fishing-out problem (most obvious inventions first), $\dot A_i$ decreases , with $A \uparrow$, difficulty of innovation increases with state of the art of an economy
\item \mybox{Case $\Phi = 0$}: no external effects
\item \mybox{Case $\Phi > 0$}: positive external effects predominate - $\dot A_i$ increases with $A \uparrow$ - fundamental research with high spillover effects (differential calculus, electricity, semiconductors)
\end{enumerate}
\end{document}

• This solves the problem of the beginning of the text on the same vertical line. But how can I now get rid of the indent? – Mac Apr 9 '15 at 12:51
• @barbarabeeton No, as I see it. It all depends on where is that line. – user11232 Apr 9 '15 at 12:53
• @Mac: Which indent are you referring to? – user11232 Apr 9 '15 at 12:53
• \itemindent move all the items. I'm looking for a way to indent only the text after the colon! (Fishing..., no..., positive...) and all the text should be blocked on the right side. Pardon my impreciseness (partially due to language barrier) – Mac Apr 9 '15 at 13:04
• @Mac: by what amount it is to be pushed? – user11232 Apr 9 '15 at 13:05

While lists are one possible way to go, my own preference in this case would be to use tables, coupled with the power of array.sty. Just a suggestion -- I don't insist upon it -- to each their own:

\documentclass{amsart}

\usepackage{array}

\newcounter{mystep}

\begin{document}

\renewcommand{\arraystretch}{1.5}
\begin{tabular}{@{\stepcounter{mystep}}>{\romannumeral\themystep.}r>{Case\ }l<{:}p{3in}}
&$\Phi<0$&Fishing out problem (most obvious inventions first), $\dot{A}_i$ decreases, with $A\uparrow$, difficulty of innovation increases with state of the art on an economy\\
&$\Phi=0$&No external effects\\
&$\Phi>0$& positive external effects predominate -- $\dot{A}_i$ increases with $A\uparrow$ -- fundamental research with high spillover effects (differential calculus, electricity, semiconductors)
\end{tabular}

\setcounter{mystep}{0}
\begin{tabular}{@{\stepcounter{mystep}}>{\themystep.)}l>{$}l<{$}p{3.25in}}
&\rho>0&time preference rate\\
&d(j,\omega,t)&demanded quantity of goods of quality lever $j$ of industry $\omega$ at time $t$\\
&\sum_{j=0}^{\infty}&all available quality levels $j$ of a consumer good $\omega$ can be consumed at the same time (in principle) $\rightarrow$ however: only consumption of those goods with best quality adjusted price.
\end{tabular}

\end{document}

• I already tried some tabular environments. But your way looks nice. How can I change the numeration-symbols? I will play around with changing the them :) – Mac Apr 10 '15 at 14:00
• The operative part of the code is, in the first example, >{\romannumeral\themystep.} and in the second example, >{\themystep.)} The first gives a lowercase roman numeral while the second gives number.dot.rightparen. This uses the > feature of array.sty which allows you to put something into a tabular cell. >{\Alph{mystep}.} for example, would yield an uppercase letter and a period for the numeration. – sgmoye Apr 10 '15 at 15:46

Use flushleft for the identical sized cases and let the rest be fully justified by LaTeX

\documentclass[15pt, a4paper]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{enumitem}
\begin{document}
%Note: assuming all case descriptors are of the same size, then just wrap with \flushleft{}
\begin{enumerate}
%    \item \parbox{\widthof{Case $\Phi < 0$:xxxxx}}{Case $\Phi < 0$:} Fishing-out problem (most obvious inventions first), $\dot A_i$ decreases , with $A \uparrow$, difficulty of innovation increases with state of the art of an economy
\item \flushleft{Case $\Phi < 0$:} Fishing-out problem (most obvious inventions first), $\dot A_i$ decreases , with $A \uparrow$, difficulty of innovation increases with state of the art of an economy
\item \flushleft{Case $\Phi = 0$:} no external effects
\item \flushleft{Case $\Phi > 0$:} positive external effects predominate - $\dot A_i$ increases with $A \uparrow$ - fundamental research with high spillover effects (differential calculus, electricity, semiconductors)
\end{enumerate}
\end{document}
• You mean I need to find the absolut value of longest element each time manually? How do I have to modify your code? – Mac Apr 9 '15 at 12:29
• @Mac From your MWE, I assumed that your problem was that the LaTeX justification algorithm was stretching the math labels thereby making the identically sized cases look different. The note about calc is obsolete and I will remove it. However, if your math items are not identical the problem is more difficult as LaTeX has no ability to look ahead in the parser. If you actually have different sized case descriptors then you either have to manually determine the max sized one or carefully pad all of them to the same length. An automated solution is beyond by training, I'm not a 'wizard' yet. – R. Schumacher Apr 9 '15 at 12:33