1

How come my custom \commonroot symbol gets "destroyed" when being used 1 level deeper in the nesting?

MWE

\documentclass{article}

\usepackage{graphicx}


\NewDocumentCommand{\lex}{>{\SplitArgument{1}{,}}m}{\lexAUX#1}

\NewDocumentCommand{\lexAUX}{mm}{%
    \textit{#1}%
    \IfValueT{#2}{\textup{\textsubscript{\textsc{#2}}}}%
}

\NewDocumentCommand{\commonroot}{}{%
    \raisebox{-0.5ex}{\rotatebox{45}{\textleftarrow\!\!}}\kern0.025em%
    \raisebox{0.5525ex}{\rotatebox{-45}{\!\!\textrightarrow}}}

\NewDocumentCommand{\coolsource}{mm}{%
    \textup{\{}\lex{#1}{\commonroot}\lex{#2}\textup{\}}}

\NewDocumentCommand{\coolderivback}{mm}{%
    \textup{\{}\lex{#1}\kern0.25em\textleftarrow\kern0.25em\lex{#2}\textup{\}}}

\NewDocumentCommand{\sourceback}{mmm}{%
    \coolderivback{\coolsource{#1}{#2}}{#3}}    


\begin{document}
    

        \coolsource{rétracter,v}{rétraction,n}
        
        \sourceback{rétracter,v}{rétraction,n}{retraire,v}
    

\end{document}


enter image description here

EDIT

The actual symbol in my file, where I use Times New Roman, looks like on the following picture, and I don't want to use math mode:

enter image description here

2
  • 1
    What is the meaning of this symbol?
    – projetmbc
    Feb 27 at 10:44
  • 1
    Both lexemes share a common ancestor. Feb 27 at 10:45

2 Answers 2

2

If you add a printing character such as !

\NewDocumentCommand{\commonroot}{}{!%
    \raisebox{-0.5ex}{\rotatebox{45}{\textleftarrow\!\!}}\kern0.025em%
    \raisebox{0.553ex}{\rotatebox{-45}{\!\!\textrightarrow}}}

you see

enter image description here

which makes it clear you are in a different font setting.

adding \textup normalises things

enter image description here


\NewDocumentCommand{\commonroot}{}{\textup{!%
    \raisebox{-0.5ex}{\rotatebox{45}{\textleftarrow\!\!}}\kern0.025em%
    \raisebox{0.553ex}{\rotatebox{-45}{\!\!\textrightarrow}}}}
2
  • Wow, brilliant. I would never have thought of this, and yet it's so simple. Since \lex italicizes its content, we need to straighten whatever shouldn't be italicized. Thank you David! Feb 26 at 18:46
  • Funny thing is, I did it with braces, and didn't think of doing it with the central symbol. Feb 26 at 20:00
1

You can use math symbols that are unaffected by the current text font.

\documentclass{article}
\usepackage{xparse}

% Define the 'lex' command for lexical entries
\NewDocumentCommand{\lex}{>{\SplitArgument{1}{,}}m}{\lexAUX#1}

% Auxiliary command to handle 'lex' arguments
\NewDocumentCommand{\lexAUX}{mm}{%
    \textit{#1}%
    \IfValueT{#2}{\textsubscript{\textup{\textsc{#2}}}}%
}

% Define the 'commonroot' symbol
%\NewDocumentCommand{\commonroot}{}{%
%    \raisebox{-0.5ex}{\rotatebox{45}{\textleftarrow\!\!}}\kern0.025em%
%    \raisebox{0.553ex}{\rotatebox{-45}{\!\!\textrightarrow}}}
\NewDocumentCommand{\commonroot}{}{%
  \ensuremath{\scriptstyle{\swarrow}\mkern-2.6mu{\searrow}}%
}


% Define the 'coolsource' command
\NewDocumentCommand{\coolsource}{mm}{%
    \textup{\{}\lex{#1}{\commonroot}\lex{#2}\textup{\}}}

% Define the 'coolderivback' command
\NewDocumentCommand{\coolderivback}{mmg}{%
    \textup{\{}\lex{#1}\kern0.25em\textleftarrow\kern0.25em
    \lex{#2}\IfValueT{#3}{\kern0.25em\textleftarrow\kern0.25em
    \lex{#3}}\textup{\}}}

% Define the 'sourceback' command
\NewDocumentCommand{\sourceback}{mmm}{%
    \coolderivback{\coolsource{#1}{#2}}{#3}}    

\begin{document}
    
    \sourceback{rétracter,v}{rétraction,n}{retraire,v}
    
    \coolsource{rétracter,n}{rétraction,n}
    
\end{document}

enter image description here

You can get arrows compatible with Times New Roman using STIX Two.

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphicx}

\setmainfont{Times New Roman}

\newfontface{\arrows}{STIX Two Math}[Scale=0.7]

\NewDocumentCommand{\lex}{>{\SplitArgument{1}{,}}m}{\lexAUX#1}

\NewDocumentCommand{\lexAUX}{mm}{%
    \textit{#1}%
    \IfValueT{#2}{\textsubscript{\textup{\textsc{#2}}}}%
}

\NewDocumentCommand{\commonroot}{}{%
  \raisebox{\depth}{%
    \normalfont\arrows
    \kern0.225em
    \symbol{"2199}\kern-0.225em\symbol{"2198}%
    \kern0.225em
  }%
}
%\NewDocumentCommand{\commonroot}{}{%
%    \raisebox{-0.5ex}{\rotatebox{45}{\textleftarrow\!\!}}\kern0.025em%
%    \raisebox{0.5525ex}{\rotatebox{-45}{\!\!\textrightarrow}}}

\NewDocumentCommand{\coolsource}{mm}{%
    \textup{\{}\lex{#1}{\commonroot}\lex{#2}\textup{\}}}

\NewDocumentCommand{\coolderivback}{mm}{%
    \textup{\{}\lex{#1}\kern0.25em\textleftarrow\kern0.25em\lex{#2}\textup{\}}}

\NewDocumentCommand{\sourceback}{mmm}{%
    \coolderivback{\coolsource{#1}{#2}}{#3}}    


\begin{document}

        \coolsource{rétracter,v}{rétraction,n}
        
        \sourceback{rétracter,v}{rétraction,n}{retraire,v}

\end{document}

enter image description here

8
  • Oh yes but I want text mode. In my actual file the symbol looks like on the picture I have just added in my OP. Feb 26 at 20:48
  • @VincentKrebs 1. Did I use math mode in the document? No. 2. The argument specifier g requires loading xparse.
    – egreg
    Feb 26 at 21:44
  • Mh not sure why you make this distinction: with your definition of \commonroot I get a math-style font instead of the text font I want. Yeah on your advice I removed the g argument, so I removed xparse as well. Thanks! Feb 26 at 22:15
  • @VincentKrebs Your example is too minimal. If you add what “Times New Roman” and what engine you use, I can surely adapt the answer to get arrows compatible with your setting.
    – egreg
    Feb 26 at 22:35
  • 1
    @VincentKrebs Added.
    – egreg
    Feb 26 at 23:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .