From d1f4d483eee9d0c2e75c6915bb559c65992a7cde Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 9 Jun 2017 22:29:17 +0000 Subject: easyformat (9jun17) git-svn-id: svn://tug.org/texlive/trunk@44543 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/doc/latex/easyformat/easyformat.pdf | Bin 47204 -> 47183 bytes .../texmf-dist/doc/latex/easyformat/easyformat.tex | 226 ++++++++++------ .../texmf-dist/tex/latex/easyformat/easyformat.sty | 299 +++++++++------------ 3 files changed, 282 insertions(+), 243 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf b/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf index 94ebdff9d10..35c2a89dac2 100644 Binary files a/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf and b/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf differ diff --git a/Master/texmf-dist/doc/latex/easyformat/easyformat.tex b/Master/texmf-dist/doc/latex/easyformat/easyformat.tex index 78c8a0aa999..6cc49cd4d29 100644 --- a/Master/texmf-dist/doc/latex/easyformat/easyformat.tex +++ b/Master/texmf-dist/doc/latex/easyformat/easyformat.tex @@ -1,17 +1,20 @@ % !TeX spellcheck = en_GB -\documentclass[a4paper, 11pt]{article} +\documentclass[11pt, cm-default]{l3doc} +% 11pt and keep on using the Computer Modern. +% We want to maintain the original look of +% our documentation so away with the coloured +% links and references as wel ↓↓↓ +\hypersetup{hidelinks} + \usepackage[british]{babel} -\usepackage[hidelinks]{hyperref} \usepackage{microtype} \usepackage{easyformat} \def\labelitemi{--} -\def\easyformat{\texttt{easyformat}} - -\title{\easyformat\\[.5em] - \large _the_ manual for the 2017/05/28 version (v1.3.0)} +\title{\pkg{easyformat}\\[.5em] + \large _the_ manual for the 2017/06/03 version (v1.4.0)} \author{Evert Provoost} @@ -22,7 +25,7 @@ \maketitle \begin{abstract} - \easyformat\ is a package that allows the use of~\verb|_| to begin/end _italic_ or __bold__ and \verb|^| to begin/end ^smallcaps^. As an alternative to the standard \LaTeX\ \verb|\textit{italic}|, \verb|\textbf{bold}| and \verb|\textsc{smallcaps}|. + \pkg{easyformat} is a package that allows the use of~|_| to begin/end _italics_ or __boldface__ and |^| to begin/end ^smallcaps^. As an alternative to the standard \LaTeX\ |\textit{italic}|, |\textbf{bold}| and |\textsc{smallcaps}|. \end{abstract} \tableofcontents @@ -36,7 +39,7 @@ %\newpage \section{Introduction} - Usually when you want to make something _italic_ or __bold__ in \LaTeX\ you insert \verb|\textit{italic}| or \verb|\textbf{bold}| respectively. + Usually when you want to make something _italic_ or __bold__ in \LaTeX\ you insert |\textit{italic}| or |\textbf{bold}| respectively. However when writing a book or another text where this formatting is common, this quickly becomes annoying to type. @@ -48,28 +51,28 @@ Simple markuplanguages (eg. Markdown) have a more elegant solution. If you, for example, wanted to write: \begin{quote} - __Stop!__, you _have_ to wait! + __Stop!__ You _have_ to wait! \end{quote} In Markdown, you'd type: \begin{quote} - \verb|**Stop!**, you *have* to wait!| + |**Stop!** You *have* to wait!| \end{quote} As you can see it's a matter of _wanting_ italic or bold formatting, adding~*'s where needed and done; no (long) macros to type. - With the help of \easyformat\ we can do something similar, here we get the same result with: + With the help of \pkg{easyformat} we can do something similar, here we get the same result with: \begin{quote} - \verb|__Stop!__, you _have_ to wait!| + |__Stop!__ You _have_ to wait!| \end{quote} (Why underscores? See: \ref{Why?!})\\ - And since it is good practice to add abbreviations using ^smallcaps^, \easyformat\ gives you \verb|^smallcaps^|. + And since it is good practice to add abbreviations using ^smallcaps^, \pkg{easyformat} gives you |^smallcaps^|. So: \begin{quote} - \verb|^nasa^ and ^esa^ are probably the best known space agencies.| + |^nasa^ and ^esa^ are probably the best known space agencies.| \end{quote} Results in: @@ -78,28 +81,29 @@ \end{quote} \section{Usage, syntax and examples} - Like usual you import the package with: \verb|\usepackage{easyformat}| + Like usual you import the package with: |\usepackage{easyformat}| - \easyformat\ makes \verb|_| an active character, however it was already `special' before so you still have to type~\verb|\_| if you want to insert an underscore. + \pkg{easyformat} makes |_| an active character, however it was already `special' before so you still have to type~|\_| if you want to insert an underscore. - The same can be said of \verb|^|, however since this one is difficult to add in ordinary \LaTeX, the \easyformat\ package gives you \verb|\cir| to get \cir. + The same can be said of |^|, however since this one is difficult to add in ordinary \LaTeX, the \pkg{easyformat} package gives you |\cir| to get \cir. \newpage - As already said, \easyformat\ uses a Markdown-like syntax, so: + As already said, \pkg{easyformat} uses a Markdown-like syntax, so: \begin{quote} - \verb|_italic,_ __bold,__, ___bolditalic___ and ^smallcaps!^| + |_italic,_ __bold,__ ___bolditalic___ and ^smallcaps!^| \end{quote} Gives: \begin{quote} - _italic,_ __bold,__, ___bolditalic___ and ^smallcaps!^ + _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.| + |_Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__|\\ + |_zet_tim, liefkan.| \end{quote} Becomes: @@ -107,83 +111,147 @@ _Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__ _zet_tim, liefkan. \end{quote} - Those with a good eye might have noticed that \easyformat\ adds italics correction when needed. Just like \verb|\textit{zet}tim| would have. + Those with a good eye might have noticed that \pkg{easyformat} adds italics correction when needed. Just like |\textit{zet}tim| would have. \section{Troubleshooting} - \easyformat\ tends to conflict with the loading of other packages, therefore you should probably load \easyformat\ last. + \pkg{easyformat} tends to conflict with the loading of other packages, therefore you should probably load \pkg{easyformat} last. \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. + 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 \pkg{easyformat} works you can get weird results. - %__Explanation:__ when you start eg. _italics_ with \verb|_|, \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. + %__Explanation:__ when you start eg. _italics_ with |_|, \pkg{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: + %If you ever try something similar to |\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: %\begin{quote} - % \verb|\setundsub|\\ + % |\setundsub|\\ % % Yeah there's a glitch were the first is indented slightly more % % unless there is something before the next lines...... - % \hspace*{0pt}\verb|\section{$\textbf{Vectors:} \vec{F}_g$}|\\ - % \hspace*{0pt}\verb|\setundact| + % \hspace*{0pt}|\section{$\textbf{Vectors:} \vec{F}_g$}|\\ + % \hspace*{0pt}|\setundact| %\end{quote} - %This first resets the \verb|_| character so it can only be used as the start of %subscripts; then adds the subtitle and afterwards re-initiates \verb|_| for %__bold__ and _italic_. (Obviously the \easyformat\ syntax does not work %_in_ the subtitle, so you'll have to use the \LaTeX-commands.) + %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 \pkg{easyformat}-syntax does not work _in_ the subtitle, so you'll have to use the \LaTeX-commands.) + + \newpage \section{Macros} \subsection{Special characters} - \noindent\fbox{\texttt{\textbackslash cir}} - Insert a 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.\\ - - \noindent\fbox{\texttt{\textbackslash disableeasyformat}} - Disables the \easyformat\ syntax.\\ + \begin{function}{\cir} + \begin{syntax} + \cs{cir} + \end{syntax} + Insert a circumflex (\cir) character. + \end{function} + + %%\subsection{Fonts} + % Removed in v1.4.0 + %\begin{function}{\nrfamily} + % \begin{syntax} + % \cs{nrfamily} + % \end{syntax} + % Reverts the font family to the default. + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\nrshape} + % \begin{syntax} + % \cs{nrshape} + % \end{syntax} + % Reverts the font shape to the default. + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\nrseries} + % \begin{syntax} + % \cs{nrseries} + % \end{syntax} + % Reverts the font series to the default. + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\setffamily} + % \begin{syntax} + % \cs{setffamily} \Arg{font family} + % \end{syntax} + % Quickly change the font family. + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\setfshape} + % \begin{syntax} + % \cs{setfshape} \Arg{font shape} + % \end{syntax} + % Quickly change the font shape. + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\setfseries} + % \begin{syntax} + % \cs{setfseries} \Arg{font series} + % \end{syntax} + % Quickly change the font series. + %\end{function} - \noindent\fbox{\texttt{\textbackslash setciract}} - Sets the catcode of \verb|^| to 13 (active).\\ + \subsection{\pkg{easyformat}-syntax} + \begin{function}{\enableeasyformat} + \begin{syntax} + \cs{enableeasyformat} + \end{syntax} + Enables the \pkg{easyformat}-syntax. + \end{function} - \noindent\fbox{\texttt{\textbackslash setcirsup}} - Sets the catcode of \verb|^| to 7 (superscript).\\ - - \noindent\fbox{\texttt{\textbackslash setundact}} - Sets the catcode of \verb|_| to 13 (active).\\ - - \noindent\fbox{\texttt{\textbackslash setundsub}} - Sets the catcode of \verb|_| to 8 (subscript). + \begin{function}{\disableeasyformat} + \begin{syntax} + \cs{disableeasyformat} + \end{syntax} + Disables the \pkg{easyformat}-syntax. + \end{function} + % Removed in v1.4.0 + %\begin{function}{\setciract} + % \begin{syntax} + % \cs{setciract} + % \end{syntax} + % Sets the catcode of |^| to 13 (active). + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\setcirsup} + % \begin{syntax} + % \cs{setcirsup} + % \end{syntax} + % Sets the catcode of |^| to 7 (superscript). + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\setundact} + % \begin{syntax} + % \cs{setundact} + % \end{syntax} + % Sets the catcode of |_| to 13 (active). + %\end{function} + + % Removed in v1.4.0 + %\begin{function}{\setundsub} + % \begin{syntax} + % \cs{setundsub} + % \end{syntax} + % Sets the catcode of |_| to 8 (subscript). + %\end{function} + \section{Technical details} \subsection{Why \texttt{\_} and not *?\label{Why?!}} - To make * work we would have to make it an active character, however this would break things like \verb|\section*{Art}|. The~\verb|_| is already protected by \TeX\ because of it's meaning in mathmode. However, it has little to no use in textmode. This is why we can use~\verb|_| for this purpose and not~*. + To make * work we would have to make it an active character, however this would break things like |\section*{Art}|. The~|_| is already protected by \TeX\ because of it's meaning in mathmode. However, it has little to no use in textmode. This is why we can use~|_| for this purpose and not~*. \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.) + No it doesn't. |_| and |^| keep behaving like before in mathmode, their meaning only changes in textmode. (We first check whether we are in mathmode or not and then behave accordingly.) \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} @@ -192,18 +260,24 @@ \section{Changelog} We only include important changes from v1.0.0 onwards, since earlier versions barely worked. + \subsection*{2017/06/03 v1.4.0} + Improved code readability. + We now fully use \pkg{expl3}, which eliminates most of the possible future issues with \LaTeX3. + Fixed a kerning issue with |\cir| in mathmode. + Removed: |\setundact|, |\setundsub|, |\setciract|, |\setcirsup|, |\nrfamily|, |\nrshape|, |\nrseries|, |\setffamily|, |\setfshape| and |\setfseries| as these do not add any value to the package. + \subsection*{2017/05/28 v1.3.0} - Removed forced re-enabling of the \easyformat-syntax at the start of the document. - Rewritten to use \texttt{expl3}, this makes the code shorter and a future move to \LaTeX3 easier. - Fixed an error that could occur with \verb|\cir|. - \easyformat\ now also behaves correctly when a fontpackage is loaded. + Removed forced re-enabling of the \pkg{easyformat}-syntax at the start of the document. + Rewritten to use \pkg{expl3}, this makes the code shorter and a future move to \LaTeX3 easier. + Fixed an error that could occur with |\cir|. + \pkg{easyformat} now also behaves correctly when a fontpackage is loaded. \subsection*{2017/04/17 v1.2.0} Improved handling of mixed styles. - Added \verb|^smallcaps^| for ^smallcaps^. + Added |^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). + Made usage of syntax in |\section{}|, and similar macros, possible. Changed the behaviour so it works more like |\emph{}| (this also simplifies the code). \subsection*{2017/04/07 v1.0.0} First stable version. diff --git a/Master/texmf-dist/tex/latex/easyformat/easyformat.sty b/Master/texmf-dist/tex/latex/easyformat/easyformat.sty index ca3f6db334e..9b8bc4424dd 100644 --- a/Master/texmf-dist/tex/latex/easyformat/easyformat.sty +++ b/Master/texmf-dist/tex/latex/easyformat/easyformat.sty @@ -19,203 +19,168 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% NOTE TO FUTURE: Italics correction works because of \maybe@ic, -% this macro might become \xfss_maybe_ic: in LaTeX3 -% -% In LaTeX3 the `New Font Selection Scheme' is replaced -% by xfss (xfont). Moving will require some research. - - -%% WAIT! This package doesn't use the LaTeX3 naming conventions?! -% Yeah, since we make _ an active character, we can't. Sorry. +%% NOTE TO THE FUTURE: +% In LaTeX3 the `New Font Selection Scheme' is replaced +% by XFSS (xfont). Moving will require some research. %% Administration... -\RequirePackage{expl3}[2015/11/11] +\RequirePackage{expl3}[2016/04/21] \ProvidesExplPackage - {easyformat} - {2017/05/28} - {1.3.0} - {Easily add boldface, italics and smallcaps.} + {easyformat} + {2017/06/03} + {1.4.0} + {Easily add boldface, italics and smallcaps.} %% Public macros % Add macros to switch the syntax on or off. -\cs_new:Npn \setundact { - \char_set_catcode_active:N {\_} -} - -\cs_new:Npn \setundsub { - \char_set_catcode_math_subscript:N {\_} -} - -\cs_new:Npn \setciract { - \char_set_catcode_active:N {\^} -} - -\cs_new:Npn \setcirsup { - \char_set_catcode_math_superscript:N {\^} -} - -\cs_new:Npn \enableeasyformat { - \setundact - \setciract -} - -\cs_new:Npn \disableeasyformat { - \setundsub - \setcirsup -} - -% Add macros which change the fontshape, fontseries and fontfamily. -\cs_new:Npn \setffamily #1 { - \fontfamily{#1} - \selectfont -} - -\cs_new:Npn \setfshape #1 { - \fontshape{#1} - \selectfont -} - -\cs_new:Npn \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 :) -\cs_new:Npn \nrfamily { - \setffamily {\familydefault} -} - -\cs_new:Npn \nrshape { - \setfshape {\shapedefault} -} - -\cs_new:Npn \nrseries { - \setfseries {\seriesdefault} -} +\cs_new:Npn \enableeasyformat + { + \char_set_catcode_active:N _ + \char_set_catcode_active:N ^ + } + +\cs_new:Npn \disableeasyformat + { + \char_set_catcode_math_subscript:N _ + \char_set_catcode_math_superscript:N ^ + } % Add a macro LaTeX should have... -% The protected to fix the double superscript error. -\cs_new_protected:Npn \cir {\char_generate:nn {`^} {12}} +% Which is protected to fix the double superscript error +% and able to give correct kerning in mathmode. +\cs_new_protected:Npn \cir + { + \mode_if_math:TF + { \hat{} } + { \c_circumflex_str } + } -%% Constants & Variables -% Yes I could use \sb and \sp but those are dependencies... -\tl_const:Nx \EFOR@subscript {\char_generate:nn {`_} {8}} -\tl_const:Nx \EFOR@superscript {\char_generate:nn {`^} {7}} - +%% Variables % Remember the style before changing to italics/boldface/smallcaps. -\str_new:N \EFOR@prev@shape@it -\str_new:N \EFOR@prev@shape@sc -\str_new:N \EFOR@prev@series@bf -\str_set:Nx \EFOR@prev@shape@it {\shapedefault} % Used by italics. -\str_set:Nx \EFOR@prev@shape@sc {\shapedefault} % Used by smallcaps. -\str_set:Nx \EFOR@prev@series@bf {\seriesdefault} % Used by boldface. +\str_new:N \l__prev_shape_str +\str_set_eq:NN \l__prev_shape_str \shapedefault + +\str_new:N \l__prev_case_str +% Case is the option used in XFSS, however do note that in +% LaTeX2e's NFSS, smallcaps is a kind of shape. +\str_set_eq:NN \l__prev_case_str \shapedefault + +\str_new:N \l__prev_series_str +\str_set_eq:NN \l__prev_series_str \seriesdefault %% Formating handling +% Add macros which change the font shape and font series. +\cs_new:Npn \__font_set_shape:n #1 + { + \fontshape {#1} + \selectfont + } + +\cs_new:Npn \__font_set_series:n #1 + { + \fontseries {#1} + \selectfont + } + % Switch italics on or off. -\cs_new:Npn \EFOR@handle@italics { - \str_if_eq:NNTF \f@shape \itdefault - { - \setfshape {\EFOR@prev@shape@it} - \str_set:Nx \EFOR@prev@shape@it {\shapedefault} - % \maybe@ic adds italics correction if needed. - % (might stop working in LaTeX3?) - \maybe@ic - }{ - \str_set:Nx \EFOR@prev@shape@it {\f@shape} - \itshape - } -} +\cs_new:Npn \__handle_italics: + { + \str_if_eq:NNTF \f@shape \itdefault + { + \__font_set_shape:n {\l__prev_shape_str} + \str_set_eq:NN \l__prev_shape_str \shapedefault + % \maybe@ic adds italics correction if needed. + % Probably becomes \xfss_maybe_ic: in LaTeX3. + \maybe@ic + } + { + \str_set_eq:NN \l__prev_shape_str \f@shape + \itshape + } + } % Switch smallcaps on or off. -\cs_new:Npn \EFOR@handle@smallcaps { - \str_if_eq:NNTF \f@shape \scdefault - { - \setfshape {\EFOR@prev@shape@sc} - \str_set:Nx \EFOR@prev@shape@sc {\shapedefault} - }{ - \str_set:Nx \EFOR@prev@shape@sc {\f@shape} - \scshape - } -} +\cs_new:Npn \__handle_smallcaps: + { + \str_if_eq:NNTF \f@shape \scdefault + { + \__font_set_shape:n {\l__prev_case_str} + \str_set_eq:NN \l__prev_case_str \shapedefault + } + { + \str_set_eq:NN \l__prev_case_str \f@shape + \scshape + } + } % Switch boldface on or off. -\cs_new:Npn \EFOR@handle@boldface { - \str_if_eq:NNTF \f@series \bfdefault - { - \setfseries {\EFOR@prev@series@bf} - \str_set:Nx \EFOR@prev@series@bf {\seriesdefault} - }{ - \str_set:Nx \EFOR@prev@series@bf {\f@series} - \bfseries - } -} - - -%% Aliases fo expl3 -% Make aliases for some LaTeX3 macros as _ isn't allowed later on. -\let\Expl@mode@if@math\mode_if_math:TF -\let\Expl@cs@gset@protected\cs_gset_protected:Npn -\let\Expl@peek@meaning@remove\peek_meaning_remove:NTF - - -%% Activate the systems! +\cs_new:Npn \__handle_boldface: + { + \str_if_eq:NNTF \f@series \bfdefault + { + \__font_set_series:n {\l__prev_series_str} + \str_set_eq:NN \l__prev_series_str \seriesdefault + } + { + \str_set_eq:NN \l__prev_series_str \f@series + \bfseries + } + } + + +%% Handling the syntax +% This is where the magic happens (also differentiates between +% text- and mathmode.) +% These are protected because they should also work in eg. \section{} + +% Syntax handling for the underscore: italics and boldface. +\cs_new_protected:Npn \__syntax_underscore: + { + \mode_if_math:TF + { \c_math_subscript_token } + { + \peek_charcode_remove:NTF _ + % The second underscore is removed when detected. + { \__handle_boldface: } + { \__handle_italics: } + } + } + +% Syntax handling for the circumflex: smallcaps. +\cs_new_protected:Npn \__syntax_circumflex: + { + \mode_if_math:TF + { \c_math_superscript_token } + { \__handle_smallcaps: } + } + +% Now give the underscore and the circumflex their behaviour. +\char_set_active_eq:NN _ \__syntax_underscore: +\char_set_active_eq:NN ^ \__syntax_circumflex: + + +%% Activate the systems. % First disable the Expl3 syntax as it will only cause trouble. \ExplSyntaxOff % Now enable the easyformat syntax. \enableeasyformat -% Now finally add the new syntax in the document part. -\AtBeginDocument{ - % We do not re-enable easyformat here, since that could - % cause unexpected behaviour. We tested if this causes errors. - - % NOTE: for some reason we have to use gset instead of new, no - % idea why though... - - % This is where the magic happens (also differentiates between - % the text and math mode.) - % It is protected because it should work in eg. \section{} - - \Expl@cs@gset@protected_{\Expl@mode@if@math - {\EFOR@subscript} - {\Expl@peek@meaning@remove_ - % The second underscore is removed when true. - {\EFOR@handle@boldface} - {\EFOR@handle@italics}% - }% - } - - \Expl@cs@gset@protected^{\Expl@mode@if@math - {\EFOR@superscript} - {\EFOR@handle@smallcaps}% - } -} - - -%% Cleanup aka: Disable the systems! -\AtEndDocument{ - % 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... - \disableeasyformat -} - - -%% DONE! -% Unfortunately we can't add a \disableeasyformat here, -% since that breaks more stuff than it fixes... +% DONE!!! %% IMPLEMENTATION DETAILS: %% Why not \textit/bf/sc\bgroup and \egroup? % Well actualy that was the original solution. However this % doesn't differentiate between ending itallics or ending -% boldface. The current solution does and this makes the syntax -% more predictable and generally more useful. \ No newline at end of file +% boldface. The current solution does and this makes the +% syntax more predictable and generally more useful. + +%% Why no ^^typewriter^^? +% because this doesn't add much value, in most contexts +% where a monospace font is useful there is already +% other syntax available. -- cgit v1.2.3