diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-17 22:26:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-17 22:26:09 +0000 |
commit | f0f5600c20467be8d19a1fc45b61463c26718ebe (patch) | |
tree | 137bdfc893ecc10b5b5033e58b33b71bb2a31954 | |
parent | a367543b300faf3092d5847d0b107c4dab768cfe (diff) |
easyformat (17apr17)
git-svn-id: svn://tug.org/texlive/trunk@43901 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/easyformat/README | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/easyformat/easyformat.pdf | bin | 146508 -> 168134 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/easyformat/easyformat.tex | 99 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/easyformat/easyformat.sty | 162 |
4 files changed, 204 insertions, 65 deletions
diff --git a/Master/texmf-dist/doc/latex/easyformat/README b/Master/texmf-dist/doc/latex/easyformat/README index a5e1a68d638..bc6d0d39211 100644 --- a/Master/texmf-dist/doc/latex/easyformat/README +++ b/Master/texmf-dist/doc/latex/easyformat/README @@ -1,12 +1,14 @@ -easyformat is a package that allows the use of _ (the underscore) to add italics and bold text. +easyformat is a package that allows the use of _ (the underscore) +to add italics and bold text and ^ (the circumflex) to add smallcaps. Usage: Import the package with: \usepackage{easyformat} Now you can do the following in textmode: -_italics_, __bold__, ___bolditalic___. +_italics_, __bold__, ___bolditalic___ and ^smallcaps^. -The underscore's (_) meaning in mathmode stays the same. +The underscore's (_) and circumflex's (^) meaning in +mathmode stay the same. (See easyformat.pdf for more info.) diff --git a/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf b/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf Binary files differindex 48ecdb6b477..472dac41f4e 100644 --- a/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf +++ b/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf diff --git a/Master/texmf-dist/doc/latex/easyformat/easyformat.tex b/Master/texmf-dist/doc/latex/easyformat/easyformat.tex index a0f544a76ff..904680da685 100644 --- a/Master/texmf-dist/doc/latex/easyformat/easyformat.tex +++ b/Master/texmf-dist/doc/latex/easyformat/easyformat.tex @@ -11,7 +11,7 @@ \def\easyformat{\texttt{easyformat}} \title{\easyformat\\[.5em] - \large _the_ manual for the 2017/04/09 version (v1.1.0)} + \large _the_ manual for the 2017/04/17 version (v1.2.0)} \author{Evert Provoost} @@ -22,10 +22,10 @@ \maketitle \begin{abstract} - \easyformat\ is a package that allows the use of~\_ to begin/end _italic_ or __bold__ formatting as an alternative to the standard \LaTeXe\ \verb|\textit{italic}| and/or \verb|\textbf{bold}|. + \easyformat\ is a package that allows the use of~\_ to begin/end _italic_ or __bold__ and \cir\ to begin/end ^smallcaps^. As an alternative to the standard \LaTeXe\ \verb|\textit{italic}|, \verb|\textbf{bold}| and \verb|\textsc{smallcaps}|. \end{abstract} - %\tableofcontents % NOT NEEDED + \tableofcontents \newpage %% NOT NEEDED. @@ -63,38 +63,63 @@ \verb|__Stop!__, you _have_ to wait!| \end{quote} - (Why underscores? See: \ref{Why?!}) + (Why underscores? See: \ref{Why?!})\\ + + And since it is good practice to add abbreviations using ^smallcaps^, \easyformat\ gives you \verb|^smallcaps^|. + + So: + \begin{quote} + \verb|^nasa^ and ^esa^ are probably the best known space agencies.| + \end{quote} + + Results in: + \begin{quote} + ^nasa^ and ^esa^ are probably the best known space agencies. + \end{quote} \section{Usage, syntax and examples} Like usual you import the package with: \verb|\usepackage{easyformat}| \easyformat\ makes \_ an active character, however it was already 'special' before so you still have to type~\verb|\_| if you want to insert an underscore. + + The same can be said of \cir, however since this one is difficult to add in ordinary \LaTeX, the \easyformat\ package gives you \verb|\cir| to get \cir. + + \newpage As already said, \easyformat\ uses a Markdown-like syntax, so: \begin{quote} - \verb|_italic,_ __bold,__ and ___bolditalic!___| + \verb|_italic,_ __bold,__, ___bolditalic___ and ^smallcaps!^| \end{quote} Gives: \begin{quote} - _italic,_ __bold,__ and ___bolditalic!___ + _italic,_ __bold,__, ___bolditalic___ and ^smallcaps!^ \end{quote} However we can also do more complex stuff, eg.: \begin{quote} - \verb|_Lorem __ipsum_ totalem__ da __givea _zin_ doram__ _zet_tim, liefkan.| + \verb|_Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__ _zet_tim, liefkan.| \end{quote} Becomes: \begin{quote} - _Lorem __ipsum_ totalem__ da __givea _zin_ doram__ _zet_tim, liefkan. + _Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__ _zet_tim, liefkan. \end{quote} - Those with a good eye might have noticed that \easyformat\ adds italicscorrection when needed. Just like \verb|\textit{zet}tim| would have. + Those with a good eye might have noticed that \easyformat\ adds italics correction when needed. Just like \verb|\textit{zet}tim| would have. - \section{Utilities} - %% This is solved in version 2017/04/09 + \section{Troubleshooting} + \begin{quotation} + ``For some or other reason I get some weird formatting\dots'' + \end{quotation} + + It could be a bug---in which case I'd love to hear from you (see \ref{contact})---however, you probably forgot to close your formatting somewhere and because of how \easyformat\ works you can get weird results. + + %__Explanation:__ when you start eg. _italics_ with \_, \easyformat\ %remembers the shape (the same is true for ^smallcaps^, when you %start __boldface__ it remembers the series) of the font. When you %get out of _italics_, it resets the shape (respectively the series) %to what it was before the starting the formatting. + + + %% This is solved in version 2017/04/09 v1.1.0 %\subsection{Underscore in subtitles\label{undtitles}} %If you ever try something similar to \verb|\section{__Vectors:__ %$\vec{F}_g$}|: \TeX\ will shout at you. Why? I don't really know. However I %do know how to fix this. If we want to get the previous example we would use: @@ -108,17 +133,48 @@ %This first resets the \_ character so it can only be used as the start of %subscripts; then adds the subtitle and afterwards re-initiates \_ for %__bold__ and _italic_. (Obviously the \easyformat\ syntax does not work %_in_ the subtitle, so you'll have to use the \LaTeX-commands.) - \subsection{\texttt{\textbackslash nrshape}} - Reverts the fontshape to the default. + \section{Macros} + \subsection{Special characters} + \noindent\fbox{\texttt{\textbackslash cir}} + Add the circumflex (\cir) character. + + \subsection{Fonts} + \noindent\fbox{\texttt{\textbackslash nrfamily}} + Reverts the fontfamily to the default.\\ + + \noindent\fbox{\texttt{\textbackslash nrshape}} + Reverts the fontshape to the default.\\ + + \noindent\fbox{\texttt{\textbackslash nrseries}} + Reverts the fontseries to the default.\\ + + \noindent\fbox{\texttt{\textbackslash setffamily\{_fontfamily_\}}} + Quickly change the fontfamily.\\ + + \noindent\fbox{\texttt{\textbackslash setfshape\{_fontshape_\}}} + Quickly change the fontshape.\\ + + \noindent\fbox{\texttt{\textbackslash setfseries\{_fontseries_\}}} + Quickly change the fontseries. + + \subsection{\easyformat\ syntax} + \noindent\fbox{\texttt{\textbackslash enableeasyformat}} + Enables the \easyformat\ syntax.\\ - \subsection{\texttt{\textbackslash nrseries}} - Reverts the fontseries to the default. + \noindent\fbox{\texttt{\textbackslash disableeasyformat}} + Disables the \easyformat\ syntax.\\ - \subsection{\texttt{\textbackslash setundact}} - Sets the catcode of \_ to 13 (active), effectively _(re-)enabling_ the \easyformat\ syntax. + \noindent\fbox{\texttt{\textbackslash setcaract}} + Sets the catcode of \cir\ to 13 (active).\\ - \subsection{\texttt{\textbackslash setundsub}} - Sets the catcode of \_ to 8 (subscript), effectively _disabling_ the \easyformat\ syntax. + \noindent\fbox{\texttt{\textbackslash setcarsup}} + Sets the catcode of \cir\ to 7 (superscript).\\ + + \noindent\fbox{\texttt{\textbackslash setundact}} + Sets the catcode of \_ to 13 (active).\\ + + \noindent\fbox{\texttt{\textbackslash setundsub}} + Sets the catcode of \_ to 8 (subscript). \section{Technical details} \subsection{Why \_ and not *?\label{Why?!}} @@ -127,13 +183,16 @@ \subsection{Does this break mathmode?} No it doesn't. It keeps behaving like before in mathmode, it's meaning only changes in textmode. (We first check whether we are in mathmode or not and behave accordingly.) - \section{Contact} + \section{Contact\label{contact}} If you want to make suggestions or have any questions whose answer could be included in a future version of this document, you can email to this address: \url{mailto:evert.provoost@gmail.com} \newpage \section{Changelog} We only include important changes from v1.0.0 onwards, since earlier versions barely worked. + \subsection*{2017/04/17 v1.2.0} + Improved handling of mixed styles. Added \verb|^smallcaps^| for ^smallcaps^. + \subsection*{2017/04/09 v1.1.0} Made usage of syntax in \verb|\section{}|, and similar macros, possible. Changed the behaviour so it works more like \verb|\emph{}| (this also simplifies the code). diff --git a/Master/texmf-dist/tex/latex/easyformat/easyformat.sty b/Master/texmf-dist/tex/latex/easyformat/easyformat.sty index 922d09abd46..8279f8165b9 100644 --- a/Master/texmf-dist/tex/latex/easyformat/easyformat.sty +++ b/Master/texmf-dist/tex/latex/easyformat/easyformat.sty @@ -1,35 +1,38 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% easyformat Adds easier bolds and italics to LaTeX. % -% Copyright (C) 2017 Evert Provoost <evert.provoost@gmail.com> % -% % -% This program is free software: you can redistribute it and/or modify % -% it under the terms of the GNU General Public License as published by % -% the Free Software Foundation, either version 3 of the License, or % -% (at your option) any later version. % -% % -% This program is distributed in the hope that it will be useful, % -% but WITHOUT ANY WARRANTY; without even the implied warranty of % -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % -% GNU General Public License for more details. % -% % -% You should have received a copy of the GNU General Public License % -% along with this program. If not, see <http://www.gnu.org/licenses/>. % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% easyformat Easily add boldface, italics and smallcaps in LaTeX. % +% Copyright (C) 2017 Evert Provoost <evert.provoost@gmail.com> % +% % +% This program is free software: you can redistribute it and/or modify % +% it under the terms of the GNU General Public License as published by % +% the Free Software Foundation, either version 3 of the License, or % +% (at your option) any later version. % +% % +% This program is distributed in the hope that it will be useful, % +% but WITHOUT ANY WARRANTY; without even the implied warranty of % +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % +% GNU General Public License for more details. % +% % +% You should have received a copy of the GNU General Public License % +% along with this program. If not, see <http://www.gnu.org/licenses/>. % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% NOTE TO FUTURE: Italics correction works because of \maybe@ic. % this macro might disappear in LaTeX3... % -% If the New Font Selection Scheme would change, +% If the 'New Font Selection Scheme' would change, % stuff WILL break... +%% TODO: Rewrite to use expl3 so it'll be easier to switch to LaTeX3. + + %% Administration... \NeedsTeXFormat{LaTeX2e} % Why no date? We'll leave that to the imports. \ProvidesPackage{easyformat} - [2017/04/09 v1.1.0 Adds easier bolds and italics.] + [2017/04/17 v1.2.0 Easily add boldface, italics and smallcaps.] %% Import this handy package @@ -46,26 +49,73 @@ \catcode`\_=8 } +\newcommand*{\setciract}{ + \catcode`\^=\active +} + +\newcommand*{\setcirsup}{ + \catcode`\^=7 +} + +\newcommand*{\enableeasyformat}{ + \setundact + \setciract +} + +\newcommand*{\disableeasyformat}{ + \setundsub + \setcirsup +} + +% Add macros which change the fontshape, fontseries and fontfamily. +\newcommand*{\setffamily}[1]{% + \fontfamily{#1}% + \selectfont% +} + +\newcommand*{\setfshape}[1]{% + \fontshape{#1}% + \selectfont% +} + +\newcommand*{\setfseries}[1]{% + \fontseries{#1}% + \selectfont% +} + % Add some macros which do small parts of what \normalfont does. +% Were needed in v1.1.0 but let's keep them because they are useful :) +\newcommand*{\nrfamily}{% + \setffamily{\familydefault}% +} + \newcommand*{\nrshape}{% - \fontshape{\shapedefault}% - \selectfont% + \setfshape{\shapedefault}% } \newcommand*{\nrseries}{% - \fontseries{\seriesdefault}% - \selectfont% + \setfseries{\seriesdefault}% } +% Add a macro LaTeX should have... +\newcommand*{\cir}{\string^\relax} + %% CONSTANTS -% Yes I could use \sb but that is a dependency... +% Yes I could use \sb and \sp but those are dependencies... \let\EFOR@subscript=_ +\let\EFOR@superscript=^ % To test what style we're currently in. \def\EFOR@it{it} +\def\EFOR@sc{sc} \def\EFOR@bf{bx} +% Remember the style before changing to italics/boldface/smallcaps. +\edef\EFOR@prev@shape@it{\shapedefault} % Used by italics. +\edef\EFOR@prev@shape@sc{\shapedefault} % Used by smallcaps. +\edef\EFOR@prev@series@bf{\seriesdefault} % Used by boldface. + %% UTILS % So we can remove an unnecessary undescore when starting/stopping bold. @@ -81,7 +131,7 @@ } % Do the first when equal, the second if not (first or second of -% what comes *after* \EFOR@util@ifx{...}{...} that is). +% what comes _after_ \EFOR@util@ifx{...}{...} that is). \newcommand*{\EFOR@util@ifx}[2]{% \ifx#1#2\relax \expandafter\@firstoftwo @@ -93,30 +143,53 @@ %% Formating handling % Switch italics on or off. -\newcommand*{\EFOR@handle@italic}{% +\newcommand*{\EFOR@handle@italics}{% \EFOR@util@ifx{\f@shape}{\EFOR@it} - % \maybe@ic adds italics correction if needed. - % (might stop working in LaTeX3?) - {\nrshape\maybe@ic} - {\itshape}% + {% + \setfshape{\EFOR@prev@shape@it}% + \edef\EFOR@prev@shape@it{\shapedefault}% + % \maybe@ic adds italics correction if needed. + % (might stop working in LaTeX3?) + \maybe@ic% + }{% + \edef\EFOR@prev@shape@it{\f@shape}% + \itshape% + }% +} + +% Switch smallcaps on or off. +\newcommand*{\EFOR@handle@smallcaps}{% + \EFOR@util@ifx{\f@shape}{\EFOR@sc} + {% + \setfshape{\EFOR@prev@shape@sc}% + \edef\EFOR@prev@shape@sc{\shapedefault}% + }{% + \edef\EFOR@prev@shape@sc{\f@shape}% + \scshape% + }% } % Switch boldface on or off. -\newcommand*{\EFOR@handle@bold}{% +\newcommand*{\EFOR@handle@boldface}{% \EFOR@util@ifx{\f@series}{\EFOR@bf} - {\nrseries} - {\bfseries}% + {% + \setfseries{\EFOR@prev@series@bf}% + \edef\EFOR@prev@series@bf{\seriesdefault}% + }{% + \edef\EFOR@prev@series@bf{\f@series}% + \bfseries% + }% } %% Activate the systems! % Prepare the syntax in the preamble. -\setundact +\enableeasyformat % Now finally add the new syntax in the document part. \AtBeginDocument{ % Just to be sure - \setundact + \enableeasyformat % This is where the magic happens (also differentiates between % the text and math mode.) @@ -125,18 +198,23 @@ {\EFOR@subscript} {\ltx@ifnextchar@nospace_ % \EFOR@util@removeChar removes the second underscore. - {\EFOR@handle@bold\EFOR@util@removeChar} - {\EFOR@handle@italic}% + {\EFOR@handle@boldface\EFOR@util@removeChar} + {\EFOR@handle@italics}% }% } + + \protected\def^{\EFOR@util@ifmmode + {\EFOR@superscript} + {\EFOR@handle@smallcaps}% + } } % Cleanup \AtEndDocument{ - % Why no \def_\undefined? + % Why no \def_\undefined and \def^\undefined? % Because if we use this syntax in eg. \section{}, % the macro should still work in the .aux file... - \setundsub + \disableeasyformat } @@ -145,7 +223,7 @@ %% IMPLEMENTATION DETAILS: -%% Why not \textit/bf\bgroup and \egroup? +%% Why not \textit/bf/sc\bgroup and \egroup? % Well actualy that was the original solution. Hwoever this % doesn't differentiate between ending itallics or ending % boldface. The current solution does and this makes the syntax |