However, the length of the line after the bracket goes beyond the limiting margin, as \textwidth is specified within the \tabularx command. The line is extended corresponding to the length of the input specified by #1 plus the width of the bracket. Somehow I need to subtract this from \textwidth. Any suggestions?
Code: Select all
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tabularx}
\setlength{\parindent}{0pt}
\makeatletter
\newenvironment{DotCases}[1]{%
{#1}
\left\{%
\tabcolsep \z@
\def\arraystretch{1.2}% linespread: adjust as you please
\tabularx{\textwidth}%
{>{$}r<{$}>{${}}X<{$}}%
}{%
\endtabularx
\right.%
\kern -\nulldelimiterspace
}
\makeatother
\begin{document}
$
\begin{DotCases}{f(x)=}
&x \dotfill \text{too}\\
&1-x \dotfill \text{long}
\end{DotCases}
$\\
$
f(x) = 1-x \dotfill \text{right length}
$
\end{document}
Thanks =)