% \iffalse %% File: ragged2e.dtx Copyright (C) 1996 Martin Schr"oder % %\NeedsTeXFormat{LaTeX2e}[1995/12/01] %\ProvidesPackage{ragged2e} % [1996/05/30 v1.00 Ragged2e Package (MS)] % %<*driver> \NeedsTeXFormat{LaTeX2e}[1995/12/01] \documentclass{ltxdoc} \usepackage{tabularx} % in latex/packages/tools \usepackage{booktabs} % in latex/contrib/supported/booktab \usepackage{ragged2e} \GetFileInfo{ragged2e.sty} \EnableCrossrefs \RecordChanges % Gather update information %%\DisableCrossrefs% Say \DisableCrossrefs if index is ready \CodelineIndex % Index code by line number \OnlyDescription % comment out for implementation details %%\OldMakeIndex % use if your MakeIndex is pre-v2.9 \setcounter{IndexColumns}{2} \setlength{\IndexMin}{40ex} \setlength{\columnseprule}{.4pt} \addtolength{\oddsidemargin}{1cm} \addtolength{\textwidth}{-1cm} \begin{document} \DocInput{ragged2e.dtx} \PrintIndex\PrintChanges % Make sure that the index is not printed twice % (ltxdoc.cfg might have a second \PrintIndex command) \let\PrintChanges\relax \let\PrintIndex\relax \end{document} % % % Copyright (C) 1996 by Martin Schr"oder. All rights reserved. % % IMPORTANT NOTICE: % % You are not allowed to change this file. You may however copy % this file to a file with a different name and then change the % copy if you obey the restrictions on file changes described in % ragged2e.ins % % You are NOT ALLOWED to distribute this file alone. You are NOT % ALLOWED to take money for the distribution or use of this file % (or a changed version) except for a nominal charge for copying % etc. % % You are allowed to distribute this file under the condition that % it is distributed together with all files mentioned in % ragged2e.ins % % If you receive only some of these files from someone, complain! % % However, if these files are distributed by established suppliers % as part of a complete TeX distribution, and the structure of the % distribution would make it difficult to distribute the whole set % of files, *those parties* are allowed to distribute only some of % the files provided that it is made clear that the user will get % a complete distribution-set upon request to that supplier (not % me). Notice that this permission is not granted to the end % user. % % % For error reports in case of UNCHANGED versions see ragged2e.ins % % \fi % % \CheckSum{311} % %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% %% \iffalse meta-comment %% =================================================================== %% @LaTeX-style-file{ %% author = {Martin Schr\"oder}, %% version = "1.00", %% date = "1996-05-30", %% filename = "ragged2e.sty", %% address = {Martin Schr\"oder %% Friedrich-Humbert-Stra\ss{}e 124 %% D-28759 Bremen %% telephone = "+49-421-628813", %% email = "MS@Dream.HB.North.DE (Internet)", %% codetable = "ISO/ASCII", %% keywords = "Raggedright", %% dependences = "everysel", %% supported = "yes", %% docstring = "LaTeX package which defines new commands %% \Centering, \RaggedLeft, and \RaggedRight %% and new environments Center, FlushLeft, and %% FlushRight, which set ragged text and are %% easily configurable to allow hyphenation." %% } %% =================================================================== %% \fi % % \pagestyle{headings} % % \newcommand*{\file}[1] {\texttt{#1}} % \newcommand*{\plain} {\texttt{plain}} % \newcommand*{\bs} {\texttt{\symbol{'134}}} % \newcommand*{\env}[1] {\textsf{#1}} % \newcommand*{\option}[1] {\textsf{#1}} % \newcommand*{\package}[1] {\textsf{#1}} % % \changes{v1.00}{1996-05-30}{New from \package{raggedright} V 1.21} % % \hyphenation{flush-left rag-ged rag-ged-right} % % \IndexPrologue{^^A % \section*{\indexname}^^A % \markboth{\indexname}{\indexname}^^A % Numbers written in \emph{italic} refer to the page where the % corresponding entry is described, the ones % \underline{underlined} to the definition, the rest to the places % where the entry is used.} % % \newenvironment{Quote}{^^A % \begin{quote}^^A % \small^^A % \fussy^^A % }{^^A % \end{quote}^^A % } % % ^^A ----------------------------- % % \title{\unskip % The \textsf{Ragged2e}-package^^A % \thanks{^^A % The version number of this file is \fileversion, % last revised \filedate.}^^A % } % \author{Martin Schr\"oder\\[0.5ex] % \normalsize Friedrich-Humbert-Stra\ss{}e 124\\ % \normalsize D-28759 Bremen\\ % \normalsize MS@Dream.HB.North.DE (Internet)} % \date{\filedate, \LaTeX{}ed \today} % \maketitle % % ^^A ----------------------------- % % \RaggedRight % % \begin{abstract} % This package provides new commands and environments for setting % ragged text which are easy to configure to allow hyphenation. % An earlier attempt to do this was the style % \package{raggedright}\cite{raggedri} by the same author. % \end{abstract} % % % ^^A ----------------------------- % % % \tableofcontents % % ^^A ----------------------------- % % \begin{multicols}{2} % \fussy % % \setlength{\parskip}{^^A % .3\baselineskip plus.05\baselineskip minus.05\baselineskip} % % \section{The problem} % ^^A % \LaTeX{} has three commands (\cs{centering}, \cs{raggedleft}, and % \cs{raggedright}) and three environments (\env{center}, % \env{flushleft}, and \env{flushright}) to typeset ragged text. % The environments are based upon the commands (\env{center} uses % \cs{centering}, \env{flushleft} \cs{raggedright}, and % \env{flushright} \cs{raggedleft}). % % These commands have, however, one serious flaw: they render % hyphenation almost impossible, and thus the text looks \emph{too} % ragged, as the following example shows: % \setcounter{unbalance}{2} % \begin{multicols}{2} % \small\fussy % \raggedright % \cs{raggedright}:\\ % ``The \LaTeX{} document preparation system is a special version % of Donald Knuth's \TeX{} program. % \TeX{} is a sophisticated program designed to produce % high-quality typesetting, especially for mathematical text.'' % \cite[p.xiii]{lamport86} % % \newpage % \RaggedRight % \cs{RaggedRight}:\\ % ``The \LaTeX{} document preparation system is a special version % of Donald Knuth's \TeX{} program. % \TeX{} is a sophisticated program designed to produce % high-quality typesetting, especially for mathematical text.'' % \cite[p.xiii]{lamport86} % \end{multicols} % % \setcounter{unbalance}{0} % % ^^A ----------------------------- % % \section{Old ``solutions''} % % ^^A ----------------------------- % % \subsection{\LaTeX} % ^^A % \LaTeX{} defines e.\,g.\ \cs{raggedright} as follows: % \begin{macrocode} %<*latex> \def\raggedright{% \let\\=\@centercr \@rightskip\@flushglue \rightskip\@rightskip \leftskip\z@ \parindent\z@} % \end{macrocode} % Initially, \cs{@flushglue} is defined as % \begin{macrocode} \@flushglue = 0pt plus 1fil % % \end{macrocode} % % Thus the \cs{rightskip} is set to |0pt plus 1fil|. % Knuth, however warns \cite[p. 101]{KnuthTeXa}: % \begin{Quote} % ``For example, a person can set \cs{rightskip=0pt plus 1fil}, % and every line will be filled with space to the right. % But this isn't a particularly good way to make ragged-right % margins, because the infinte stretchability will assign zero % badness to lines that are very short. % To do a decent job of ragged-right setting, the trick is to set % \cs{rightskip} so that it will stretch enough to make line breaks % possible, yet not too much, because short lines should be % considered bad. % Furthermore the spaces between words should be fixed so that % they do not stretch or shrink.'' % \end{Quote} % % ^^A ----------------------------- % % \subsection{\plain{}} % ^^A % \plain{} \TeX{} defines an special version of % \cs{raggedright}, which operates the way Knuth describes it; % but which can not be used whith \LaTeX, because \LaTeX{} redefines % \cs{raggedright}. % \begin{macrocode} %<*plain> \def\raggedright{% \rightskip\z@ plus2em \spaceskip.3333em \xspaceskip.5em\relax} % \end{macrocode} % % \plain{} provides also a version of \cs{raggedright} for typewriter % fonts % \begin{macrocode} \def\ttraggedright{% \tt \rightskip\z@ plus2em\relax} % % \end{macrocode} % % \end{multicols} % \setlength{\parskip}{^^A % .3\baselineskip plus.05\baselineskip minus.05\baselineskip} % % ^^A ----------------------------- % % \section{Our solution} % % ^^A ----------------------------- % % \subsection{Usage} % % Since the \plain{} solution can not be used with \LaTeX, we have to % redefine it and make it possible to configure it for personal % preferences. % % ^^A ----------------------------- % % \subsubsection{The macros} % % \DescribeMacro{\Centering} % \DescribeMacro{\RaggedLeft} % \DescribeMacro{\RaggedRight} % \cs{Centering}, \cs{RaggedLeft}, and \cs{RaggedRight} can be used in % the same way as \cs{centering}, \cs{raggedleft}, and % \cs{raggedright}: % Just type the command, and after that the whole text will be set % centered, ragged-left or ragged-right. % % For example, we switched on \cs{RaggedRight} on the top of this % text, and consequently this text was set ragged-right. % % The new commands are fully compatible with their counterparts in \LaTeX, % but implement the \plain{} solution and can be easily configured % using the following parameters: % % ^^A ----------------------------- % % \subsubsection{The parameters} % ^^A % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X}\toprule % Command & Uses\\ \midrule % \cs{Centering} & \cs{CenteringLeftSkip}, % \cs{CenteringRightSkip}, % \cs{CenteringParfillskip}, % \cs{CenteringParIndent} % \\ % \cs{RaggedLeft} & \cs{RaggedLeftLeftskip}, % \cs{RaggedLeftRightskip}, % \cs{RaggedLeftParfillskip}, % \cs{RaggedLeftParIndent} % \\ % \cs{RaggedRight} & \cs{RaggedRightLeftskip}, % \cs{RaggedRightRightskip}, % \cs{RaggedRightParfillskip}, % \cs{RaggedRightParIndent} % \\ % \emph{all} & \cs{RaggedSpaceskip}, % \cs{RaggedXSpaceskip} \\ \bottomrule % \end{tabularx} % % All Parameters can be set with \cs{setlength}, e.\,g.\ % \begin{Quote} % |\setlength{RaggedRightRightskip}{0pt plus 1em}| % \end{Quote} % sets \cs{RaggedRightRightskip} to |0pt plus 1em|. % % \DescribeMacro{\CenteringLeftskip} % \DescribeMacro{\RaggedLeftLeftskip} % \DescribeMacro{\RaggedRightLeftskip} % These are the \cs{leftskip}s inserted by \cs{Centering}, % \cs{RaggedLeft}, and \cs{RaggedRight}. % \begin{Quote} % \setlength{\tabcolsep}{.25em} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X} % ``\cs{leftskip} & (glue at left of justified lines)'' % \cite[p.~274]{KnuthTeXa} % \end{tabularx} % \end{Quote} % \cs{leftskip} must be set to a finite value, to make hyphenation % possible. % Setting it to infinite values like |0pt plus 1fil| makes % hyphenation almost impossible. % % \DescribeMacro{\CenteringRightskip} % \DescribeMacro{\RaggedLeftRightskip} % \DescribeMacro{\RaggedRightRightskip} % These are the \cs{rightskip}s inserted by \cs{Centering}, % \cs{RaggedLeft}, and \cs{RaggedRight}. % \begin{Quote} % \setlength{\tabcolsep}{.25em} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X} % ``\cs{rightskip} & (glue at right of justified lines)'' % \cite[p.~274]{KnuthTeXa} % \end{tabularx} % \end{Quote} % \cs{rightskip} must be set to a finite value, to make hyphenation % possible. % Setting it to infinite values like |0pt plus 1fil| makes % hyphenation almost impossible. % % \DescribeMacro{\CenteringParfillskip} % \DescribeMacro{\RaggedLeftParfillskip} % \DescribeMacro{\RaggedRightParfillskip} % These are the \cs{parfillskip}s inserted by \cs{Centering}, % \cs{RaggedLeft}, and \cs{RaggedRight}. % \begin{Quote} % \setlength{\tabcolsep}{.25em} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X} % ``\cs{parfillskip} & (additional \cs{rightskip} at end of paragraphs)'' % \cite[p.~274]{KnuthTeXa} % \end{tabularx} % \end{Quote} % The normal setting for \cs{parfillskip} is |0pt plus 1fil|; the % parameters are provided for testing combinations of % \cs{}\{|left|$\mid$|right|\}|skip| and \cs{parfillskip}. % % \DescribeMacro{\CenteringParindent} % \DescribeMacro{\RaggedLeftParindent} % \DescribeMacro{\RaggedRightParindent} % These are the \cs{parindent}s used by \cs{Centering}, % \cs{RaggedLeft}, and \cs{RaggedRight}. % \begin{Quote} % \setlength{\tabcolsep}{.25em} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X} % ``\cs{parindent} & (width of \cs{indent})'' % \cite[p.~274]{KnuthTeXa} % \end{tabularx} % \end{Quote} % \cs{parindent} is the indent of the first line of a paragraph and % should be set to |0pt|, since indented lines in ragged text % do not look good. % % \DescribeMacro{\RaggedSpaceskip} % \cs{RaggedSpaceskip} is the \cs{spaceskip} used by \cs{Centering}, % \cs{RaggedLeft}, and \cs{RaggedRight}. % \begin{Quote} % \setlength{\tabcolsep}{.25em} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X} % ``\cs{spaceskip} & (glue between words, if nonzero)'' % \cite[p.~274]{KnuthTeXa} % \end{tabularx} % \end{Quote} % If \cs{spaceskip} is nonzero, the \cs{spaceskip} glue is used for an % interword space. % The \plain{} solution sets \cs{spaceskip} to |.3333em| so that the % spaces between words are fixed. % This can only be used with proportional fonts, since with monospaced % fonts like cmtt the \cs{spaceskip} should be set to the width of a % space `\texttt{\textvisiblespace}', which is e.\,g.\ |.5em| in cmtt. % So \plain{} provides the command \cs{ttraggedright} for monospaced % fonts which doesn't set \cs{spaceskip}. % % To solve this problem we use the package \package{eversel} to % distinguish between monospaced and proportional fonts. % If the current font is monospaced (\cs{fontdimen3} = |0pt|) we % set \cs{spaceskip} to the interword space defined by the font % (\cs{fontdimen2}); otherwise we use \cs{RaggedSpaceskip}.^^A % \footnote{^^A % This will \emph{not} allow hyphenation of typewriter fonts; % \LaTeX{} disables this by setting \cs{hyphenchar} to % \texttt{-1} for the \cs{ttfamily}\protect\cite{cmfonts}.} % % \DescribeMacro{\RaggedXSpaceskip} % \cs{RaggedXSpaceskip} is the \cs{xspaceskip} used by \cs{Center}, % \cs{RaggedLeft}, and \cs{RaggedRight}. % \begin{Quote} % \setlength{\tabcolsep}{.25em} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X} % ``\cs{xspaceskip} & (glue between sentences, if nonzero)'' % \cite[p.~274]{KnuthTeXa} % \end{tabularx} % \end{Quote} % \cs{xspaceskip} is the glue between sentences (after elements % with a space factor $\ge$ 2000), if nonzero. % Here we also have to distinguish between monospaced and proportional % fonts using \package{everysel}. % % The parameters have the following initial setting: % \begin{center} % \begin{tabularx}{\linewidth}{l>{\RaggedRight}X>{\RaggedRight}X}\toprule % Parameter & \LaTeX{} setting % & \package{Ragged2e} setting\\ % \midrule % \cs{CenteringLeftskip} & \ttfamily 0pt plus 1fil % & \ttfamily 0pt plus 2em\\ % \cs{RaggedLeftLeftskip} & \ttfamily 0pt plus 1fil % & \ttfamily 0pt plus 2em\\ % \cs{RaggedRightLeftskip} & \ttfamily 0pt plus 0pt minus 0pt % & \ttfamily 0pt plus 0pt minus 0pt\\ % \cs{CenteringRightskip} & \ttfamily 0pt plus 1fil % & \ttfamily 0pt plus 2em\\ % \cs{RaggedLeftRightskip} & \ttfamily 0pt plus 0pt minus 0pt % & \ttfamily 0pt plus 0pt minus 0pt \\ % \cs{RaggedRightRightskip} & \ttfamily 0pt plus 1fil % & \ttfamily 0pt plus 2em\\ % \cs{CenteringParfillskip} & \ttfamily 0pt plus 0pt minus 0pt % & \ttfamily 0pt plus 0pt minus 0pt \\ % \cs{RaggedLeftParfillskip} & \ttfamily 0pt plus 0pt minus 0pt % & \ttfamily 0pt plus 0pt minus 0pt \\ % \cs{RaggedRightParfillskip}& \ttfamily 0pt plus 1fil % & \ttfamily 0pt plus 1fil\\ % \cs{CenteringParindent} & \ttfamily 0pt % & \ttfamily 0pt \\ % \cs{RaggedLeftParindent} & \ttfamily 0pt % & \ttfamily 0pt \\ % \cs{RaggedRightParindent} & \ttfamily 0pt % & \ttfamily 0pt \\ % \cs{RaggedSpaceskip} & \ttfamily 0pt % & \texttt{0.3333em}/\linebreak[3]\cs{fontdimen2}\footnotemark\\ % \cs{RaggedXSpaceskip} & \ttfamily 0pt % & \addtocounter{footnote}{-1}\texttt{.5em}/\texttt{0pt}\footnotemark\\ % \bottomrule % \end{tabularx} % \end{center} % \footnotetext{^^A % For proportional and monospaced fonts.} % % ^^A ----------------------------- % % \subsubsection{The environments} % ^^A % \DescribeEnv{Center} % |Center| is fully compatible with |center|, but uses % \cs{Centering} instead of \cs{centering}. % % \DescribeEnv{FlushLeft} % |FlushLeft| is fully compatible with |flushleft|, but uses % \cs{RaggedRight} instead of \cs{raggedright}. % % \DescribeEnv{FlushRight} % |FlushRight| is fully compatible with |flushright|, but uses % \cs{RaggedLeft} instead of \cs{raggedleft}. % % E.\,g.\ |FlushLeft| can be used in the same way as |flushleft|: % \begin{verse} % \small % |\begin{FlushLeft}|\\ % \meta{text, which is set ragged-right}\\ % |\end{FlushLeft}| % \end{verse} % % ^^A ----------------------------- % % \section{Options} % ^^A % This package has the following options: % \nopagebreak % \begin{description} % \item[\normalfont\option{OriginalCommands}] % The \LaTeX-commands \cs{centering}, \cs{raggedleft}, and % \cs{raggedright} and the \LaTeX-environments \env{center}, % \env{flushleft}, and \env{flushright} remain unchanged.\newline % It is the default. % \item[\normalfont\option{NewCommands}] % The \LaTeX-commands \cs{centering}, \cs{raggedleft}, and % \cs{raggedright} and the \LaTeX-environments \env{center}, % \env{flushleft}, and \env{flushright} are set equal to their % counterparts defined by \package{ragged2e}. % Thus \cs{raggedright} invokes \cs{RaggedRight}. % The original commands can be accessed unter the Names % \cs{LaTeX}\meta{original name}, e.\,g.\ \cs{LaTeXraggedright}. % \item[\normalfont\option{OriginalParameters}] % The parameters used by the commands implemented by % \package{ragged2e} are initialized with the default settings % used by \LaTeX. % \item[\normalfont\option{NewParameters}] % The parameters used by the commands implemented by % \package{ragged2e} are initialized with the default settings % defined by \package{ragged2e}.\newline % It is the default. % \end{description} % % % ^^A ----------------------------- % % \section{Required packages} % ^^A % This package requires the following package: % \begin{description} % \item[\normalfont\package{everysel}\cite{everysel}] % It is used to distinguish between monospaced and proportional % fonts. % \end{description} % % % ^^A ----------------------------- % % \StopEventually{^^A % % % ^^A ----------------------------- % % \section{Acknowledgements} % ^^A % A first version of this package for \LaTeX2.09 was named % \package{raggedri}\cite{raggedri}.\newline % Laurent Siebenmann (\texttt{lcs@topo.math.u-psud.fr}) with his % style \package{ragged.sty}\cite{ragged} provided the final impulse % for this new implementation.\newline % Without the constant nagging of Rainer Sieger % (\texttt{rsieger@awi-bremerhaven.de}) this package might not be. % % ^^A Rebecca Stiels much improved the language of the documentation. % % % ^^A ----------------------------- % % \newcommand{\noopsort}[1]{} \newcommand{\printfirst}[2]{##1} % \newcommand{\singleletter}[1]{##1} \newcommand{\switchargs}[2]{##2##1} % \begin{thebibliography}{1} % % \bibitem{ltmiscen} % Johannes Braams, David Carlisle, Alan Jeffrey, Leslie Lamport, Frank % Mittelbach, Chris Rowley, and Rainer Sch{\"o}pf. % \newblock ltmiscen.dtx. % \newblock Part of the {\LaTeX}-distribution. % % \bibitem{KnuthTeXa} % Donald~E. Knuth. % \newblock \emph{The {\TeX}Book}, volume~A of \emph{Computers \& Typesetting}. % \newblock Ad{\-d}i{\-s}on-Wes{\-l}ey, Reading, MA, USA, {\noopsort{1986a}}1986. % % \bibitem{lamport86} % Leslie Lamport. % \newblock \emph{\LaTeX: A Document Preparation System}. % \newblock Ad{\-d}i{\-s}on-Wes{\-l}ey, Reading, MA, USA, first edition, 1986. % % \bibitem{cmfonts} % Frank Mittelbach and Rainer Sch{\"o}pf. % \newblock The file {\texttt{cmfonts.fdd}} for use with {\LaTeXe}. % \newblock Part of the {\LaTeX}-distribution. % % \bibitem{everysel} % Martin Schr{\"o}der. % \newblock The \textsf{everysel}-package. % \newblock \texttt{CTAN: tex-archive/macros/latex/contrib/supported/everysel}. % \newblock \LaTeXe{} package. % % \bibitem{raggedri} % Martin Schr{\"o}der. % \newblock The \textsf{raggedri} document option. % \newblock Was in \texttt{CTAN: tex-archive/macros/latex209/contrib/raggedright}. % \newblock \LaTeX2.09 style, outdated. % % \bibitem{ragged} % Laurent Siebenmann. % \newblock \texttt{ragged.sty}. % \newblock \texttt{CTAN: tex-archive/macros/generic/ragged/ragged.sty}. % \newblock generic macro file for \texttt{plain} and \LaTeX. % % \end{thebibliography} % } % % ^^A ----------------------------- % % \section{The implementation} % % \begin{macrocode} %<*package> % \end{macrocode} % % % ^^A ----------------------------- % % \subsection{Initial Code} % ^^A % \begin{macro}{\if@raggedtwoe@originalcommands} % \cs{if@raggedtwoe@originalcommands} is used to flag the use of the % \option{OriginalCommands} or \option{NewCommands} option. % \begin{macrocode} \newif\if@raggedtwoe@originalcommands % \end{macrocode} % \end{macro} % % \begin{macro}{\if@raggedtwoe@originalparameters} % \cs{if@raggedtwoe@originalparameters} is used to flag the use of the % \option{OriginalParameters} or \option{NewParameters} option. % \begin{macrocode} \newif\if@raggedtwoe@originalparameters % \end{macrocode} % \end{macro} % % % ^^A ----------------------------- % % \subsection{Declaration of options} % % % ^^A ----------------------------- % % \subsubsection{\option{OriginalCommands} option} % ^^A % The \option{OriginalCommands} and \option{NewCommands} options % control the meaning of the \LaTeX-commands for ragged text: % If \option{NewCommands} is used the \LaTeX-commands are set equal % to the commands defined by \package{ragged2e}. % \begin{macrocode} \DeclareOption{OriginalCommands}{\@raggedtwoe@originalcommandstrue} \DeclareOption{NewCommands}{\@raggedtwoe@originalcommandsfalse} % \end{macrocode} % % % ^^A ----------------------------- % % \subsubsection{\option{OriginalParameters} option} % ^^A % The \option{OriginalParameters} and \option{NewParameters} options % control the defaults for the parameters used by the commands % implemented by \package{ragged2e}: % If \option{NewParameters} is used the parameters are set to the % values defined by \package{ragged2e}. % \begin{macrocode} \DeclareOption{OriginalParameters}{\@raggedtwoe@originalparameterstrue} \DeclareOption{NewParameters}{\@raggedtwoe@originalparametersfalse} % \end{macrocode} % % % ^^A ----------------------------- % % \subsection{Executing options} % ^^A % The default options are \option{OriginalCommands} and % \option{NewParameters}. % \begin{macrocode} \ExecuteOptions{OriginalCommands,NewParameters} \ProcessOptions\relax % \end{macrocode} % % % ^^A ----------------------------- % % \subsection{Loading packages} % ^^A % We need the \package{everysel} package. % \begin{macrocode} \RequirePackage{everysel} % \end{macrocode} % % % ^^A ----------------------------- % % \subsection{Allocations} % ^^A % \begin{macro}{\CenteringLeftskip} % \begin{macro}{\RaggedLeftLeftskip} % \begin{macro}{\RaggedRightLeftskip} % \begin{macro}{\CenteringRightskip} % \begin{macro}{\RaggedLeftRightskip} % \begin{macro}{\RaggedRightRightskip} % \begin{macro}{\CenteringParfillskip} % \begin{macro}{\RaggedLeftParfillskip} % \begin{macro}{\RaggedRightParfillskip} % \begin{macro}{\CenteringParindent} % \begin{macro}{\RaggedLeftParindent} % \begin{macro}{\RaggedRightParindent} % \begin{macro}{\RaggedSpaceskip} % \begin{macro}{\RaggedXSpaceskip} % First we allocate the parameters % \begin{macrocode} \newlength{\CenteringLeftskip} \newlength{\RaggedLeftLeftskip} \newlength{\RaggedRightLeftskip} \newlength{\CenteringRightskip} \newlength{\RaggedLeftRightskip} \newlength{\RaggedRightRightskip} \newlength{\CenteringParfillskip} \newlength{\RaggedLeftParfillskip} \newlength{\RaggedRightParfillskip} \newlength{\CenteringParindent} \newlength{\RaggedLeftParindent} \newlength{\RaggedRightParindent} \newlength{\RaggedSpaceskip} \newlength{\RaggedXSpaceskip} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % % ^^A ----------------------------- % % \subsection{Initializations} % ^^A % Depending on \cs{if@raggedtwoe@originalparameters} we initialize the % parameters with the values \LaTeX{} uses for its own commands or with % our new parameters. % \begin{macrocode} \if@raggedtwoe@originalparameters \setlength{\CenteringLeftskip} {\z@ plus \@ne fil} \setlength{\RaggedLeftLeftskip} {\z@ plus \@ne fil} \setlength{\RaggedRightLeftskip} {\z@skip} \setlength{\CenteringRightskip} {\z@ plus \@ne fil} \setlength{\RaggedLeftRightskip} {\z@skip} \setlength{\RaggedRightRightskip} {\z@ plus \@ne fil} \setlength{\CenteringParfillskip} {\z@skip} \setlength{\RaggedLeftParfillskip} {\z@skip} \setlength{\RaggedRightParfillskip} {\z@ plus \@ne fil} \setlength{\CenteringParindent} {\z@} \setlength{\RaggedLeftParindent} {\z@} \setlength{\RaggedRightParindent} {\z@} \setlength{\RaggedSpaceskip} {\z@} \setlength{\RaggedXSpaceskip} {\z@} \else \setlength{\CenteringLeftskip} {\z@ plus \tw@ em} \setlength{\RaggedLeftLeftskip} {\z@ plus \tw@ em} \setlength{\RaggedRightLeftskip} {\z@skip} \setlength{\CenteringRightskip} {\z@ plus \tw@ em} \setlength{\RaggedLeftRightskip} {\z@skip} \setlength{\RaggedRightRightskip} {\z@ plus \tw@ em} \setlength{\CenteringParfillskip} {\z@skip} \setlength{\RaggedLeftParfillskip} {\z@skip} \setlength{\RaggedRightParfillskip} {\z@ plus \@ne fil} \setlength{\CenteringParindent} {\z@} \setlength{\RaggedLeftParindent} {\z@} \setlength{\RaggedRightParindent} {\z@} \setlength{\RaggedSpaceskip} {.3333em} \setlength{\RaggedXSpaceskip} {.5em} \fi % \end{macrocode} % % % ^^A ----------------------------- % % \subsection{Setting the \cs{spaceskip} and \cs{xspaceskip}} % ^^A % To set ragged text with proportional fonts \emph{and} monospaced % fonts correctly, we must distinguish between these two kinds of % fonts \emph{everytime} a font is loaded. % Otherwise the settings for e.\,g.\ a proportional fonts would be % in effect if you start \cs{RaggedRight} in \cs{rmfamily} and % then switch to \cs{ttfamily}. % % We do the setting with the help of \package{everysel}\cite{everysel}, % which allows us to define code which is (hopefully) executed after % every fontchange in a \LaTeX{} document.\footnote{^^A % It \emph{is} executed after every \cs{selectfont}, so if you stay % within NFSS and don't declare your fonts with commands like % \cs{newfont} and then switch to them, it will work.} % % \begin{macro}{\if@raggedtwoe@spaceskip} % \cs{if@raggedtwoe@spaceskip} signals the use of commands defined by % \package{ragged2e} to the command inserted into \cs{selectfont}. % It is set to true by these commands and restored to false by \TeX{} % when the scope of them ends. % \begin{macrocode} \newif\if@raggedtwoe@spaceskip % \end{macrocode} % \end{macro} % % \begin{macro}{\@raggedtwoe@everyselectfont} % \cs{@raggedtwoe@everyselectfont} is our code inserted into % \cs{selectfont}. % \begin{macrocode} \newcommand*{\@raggedtwoe@everyselectfont}{% \if@raggedtwoe@spaceskip % \end{macrocode} % If no command defined by \package{ragged2e} is in use, we do % nothing. % But if it is, we look at \cs{fontdimen3} to see if the current % font is monospaced or not. % If it is, we set \cs{spaceskip} to the value intended by the % designer of the font (\cs{fontdimen2}) and \cs{xspaceskip} to % |0pt|. % If it isn't, we use the values defined by \cs{RaggedSpaceskip} % and \cs{RaggedXSpaceskip}. % \begin{macrocode} \ifdim\fontdimen\thr@@\font=\z@\relax \setlength{\spaceskip} {\fontdimen\tw@\font}% \setlength{\xspaceskip} {\z@}% \else \setlength{\spaceskip} {\RaggedSpaceskip}% \setlength{\xspaceskip} {\RaggedXSpaceskip}% \fi \fi } \EverySelectfont{\@raggedtwoe@everyselectfont} % \end{macrocode} % \end{macro} % % % ^^A ----------------------------- % % \subsection{The commands} % ^^A % \begin{macro}{\@raggedtwoe@savedcr} % We save the definition of |\\| in \cs{@raggedtwoe@savedcr}. % \begin{macrocode} \let\@raggedtwoe@savedcr\\ % \end{macrocode} % \end{macro} % % \begin{macro}{\Centering} % \cs{Centering} first lets |\\| = \cs{@centercr}, but only if |\\| % has its original meaning, otherwise \cs{Center} would not work % inside environments like \env{tabular} etc., in which |\\| has a % different meaning. % Then, the \LaTeX{} and \TeX-parameters are set. % \cs{@rightskip} is \LaTeX's version of \cs{rightskip}. % \begin{Quote} % ``Every environment, like the list environments, that set % \cs{rightskip} to its 'normal' value set it to \cs{@rightskip}'' % \cite{ltmiscen} % \end{Quote} % Finally we signal the code inserted into \cs{selectfont} that % we are active. % \begin{macrocode} \newcommand{\Centering}{% \ifx\\\@raggedtwoe@savedcr \let\\\@centercr \fi \setlength{\leftskip} {\CenteringLeftskip}% \setlength{\@rightskip} {\CenteringRightskip}% \setlength{\rightskip} {\@rightskip}% \setlength{\parfillskip}{\CenteringParfillskip}% \setlength{\parindent} {\CenteringParindent}% \@raggedtwoe@spaceskiptrue } % \end{macrocode} % \end{macro} % % \begin{macro}{\RaggedLeft} % \cs{RaggedLeft} is like \cs{Centering}; it only uses other % parameters. % \begin{macrocode} \newcommand{\RaggedLeft}{% \ifx\\\@raggedtwoe@savedcr \let\\\@centercr \fi \setlength{\leftskip} {\RaggedLeftLeftskip}% \setlength{\@rightskip} {\RaggedLeftRightskip}% \setlength{\rightskip} {\@rightskip}% \setlength{\parfillskip}{\RaggedLeftParfillskip}% \setlength{\parindent} {\RaggedLeftParindent}% \@raggedtwoe@spaceskiptrue } % \end{macrocode} % \end{macro} % % \begin{macro}{\RaggedRight} % \cs{RaggedRight} is like \cs{Centering}; it only uses other % parameters. % \begin{macrocode} \newcommand{\RaggedRight}{% \ifx\\\@raggedtwoe@savedcr \let\\\@centercr \fi \setlength{\leftskip} {\RaggedRightLeftskip}% \setlength{\@rightskip} {\RaggedRightRightskip}% \setlength{\rightskip} {\@rightskip}% \setlength{\parfillskip}{\RaggedRightParfillskip}% \setlength{\parindent} {\RaggedRightParindent}% \@raggedtwoe@spaceskiptrue } % \end{macrocode} % \end{macro} % % % ^^A ----------------------------- % % \subsection{The environments} % ^^A % \begin{environment}{Center} % \begin{environment}{FlushLeft} % \begin{environment}{FlushRight} % The environments \env{Center}, \env{FlushLeft}, and \cs{FlushRight} % are implemented like their counterparts in \LaTeX: Start a % \env{trivlist} and switch on the right command. % \begin{macrocode} \newenvironment{Center}{% \begin{trivlist}% \Centering\item\relax }{% \end{trivlist}% } \newenvironment{FlushLeft}{% \begin{trivlist}% \RaggedRight\item\relax }{% \end{trivlist}% } \newenvironment{FlushRight}{% \begin{trivlist}% \RaggedLeft\item\relax }{% \end{trivlist}% } % \end{macrocode} % \end{environment} % \end{environment} % \end{environment} % % % ^^A ----------------------------- % % \subsection{Overloading the \LaTeX-commands} % ^^A % If the option \option{NewCommands} is used, we save the original % \LaTeX-commands for ragged text and overload them. % \begin{macrocode} \if@raggedtwoe@originalcommands \else \let\LaTeXcentering\centering \let\LaTeXraggedleft\raggedleft \let\LaTeXraggedright\raggedright \let\LaTeXcenter\center \let\LaTeXflushleft\flushleft \let\LaTeXflushright\flushright \let\centering\Centering \let\raggedleft\RaggedLeft \let\raggedright\RaggedRight \let\begincenter\beginCenter \let\beginflushleft\beginFlushleft \let\beginflushright\beginFlushRight \fi % \end{macrocode} % % ^^A ----------------------------- % % \begin{macrocode} % % \end{macrocode} % \Finale