12

I try to get irony punctuation mark in LaTeX with CMU font. This symbol is in Unicode: ⸮ (U+U+2E2E)

So I search a way to get a correct rendering with CMU of this symbol. But the problem is the emphasis rendering of the irony mark.

As irony punct is just a mirrored interrogation mark, I use the \reflectbox command from graphicx, like in this MWE:

\documentclass{minimal}
\usepackage{graphicx}


\newcommand\irony{\,\reflectbox{?}}

\begin{document}

Roman : Lorem ipsum dolor\irony

Emphasis : \emph{Lorem ipsum dolor\irony}

Bold :  \textbf{Lorem ipsum dolor\irony}

\end{document}

But the problem is the emphasis rendering:

enter image description here

The emphasis form of the irony mark is slanted to left, when the text is slanted to right.

When the ideal form is the one with the validation check mark bellow:

enter image description here

So, is it possible to get this rendering when the \irony command is in emphasis environment or command?

  • Another option: DejaVu Serif Condensed has many Unicode symbols that don't look completely terrible mixed in with Computer Modern, although in this case the reversed question mark looks noticeably different enough from the question mark that you probably won't want to use it. – Davislor Jun 15 '18 at 1:49
  • Yes @Davislor it try DejaVu Serif but it have an ugly rendering with CMU. It isn’t what I expect. – fauve Jun 15 '18 at 2:02
  • DejaVu Serif Condensed with [Scale=MatchUppercase] is probably as good as you're going to get for a lot of symbols. – Davislor Jun 15 '18 at 2:25
11

With TikZ you have engine independence.

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

\setmainfont{CMU Serif}
\newfontfamily{\dejavu}{DejaVu Serif}

\makeatletter
\newunicodechar{⸮}{%
  \iffontchar\font`⸮
    ⸮%
  \else
    \ifdim\fontdimen1\font=\z@
      \tikz[baseline=(?.base),inner sep=0pt,outer sep=0pt]\node[xscale=-1] (?) {?};%
    \else
      \tikz[baseline=(?.base),inner sep=0pt,outer sep=0pt]\node[xscale=-1,xslant=-0.5] (?) {?};%
      \kern-0.35em
    \fi
  \fi
}
\makeatother

\begin{document}
\setlength{\fboxsep}{0pt} % for showing the bounding boxes

dolor⸮?

\textit{dolor⸮?} \fbox{\itshape     ⸮} \fbox{\itshape ?}

\dejavu
dolor⸮?

\textit{dolor⸮?}

\end{document}

The real character is used if available.

enter image description here

  • 1
    it’s a good solution because, I haven’t to use the \irony command but only the character. But is it also possible in the Tikz definition to give the U+2E2E code? Because in the final pdf the irony mark is detected as a question mark so the CTRL-F command or the copy/past failed… – fauve Jun 15 '18 at 0:43
  • 1
    @fauve You could use the accsupp package, but just a few PDF viewers support its features. – egreg Jun 15 '18 at 7:58
11

The problem is that the italics (or slant) lean the text to the right, and when you reflect it, the lean is to the left. But you already figured this out.

Bruno Le Floch devised a neat \slantbox command that applies a shear transform to a given object, so you can make a "reverse italics" then reflect the irony mark:

enter image description here

\documentclass{article}

\usepackage{graphicx}

\makeatletter
\newcommand{\slantbox}[2][.5]
  {%
    \mbox
      {%
        \sbox{\@tempboxa}{#2}%
        \hskip\wd\@tempboxa
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\@tempboxa}}%
        \pdfrestore
      }%
  }

\newcommand\irony{%
  \,%
  \ifdim\the\fontdimen\@ne\font>\z@
%                         ↓--↓ Manually tuned
    \reflectbox{\slantbox[-0.6]{?}}%
  \else
    \reflectbox{?}%
  \fi
}
\makeatother

\begin{document}

\makeatletter

Roman : Lorem ipsum dolor\irony

Emphasis : \emph{Lorem ipsum dolor\irony}

Bold : \textbf{Lorem ipsum dolor\irony}

\end{document}

I also added a conditional to check if the current font shape is italicized or not.

Unfortunately this doesn't work for XeTeX, since the \slantbox command uses pdfTeX primitives. It works for LuaTeX though :)

8

You can use a custom version of reflectbox which also applies some slant to fit with the current font:

\documentclass{minimal}

\makeatletter
\newcommand\REflectwithslant{%
  \hskip\wd0
  \wd0=0pt
  \pdfsave
  \pdfsetmatrix{%
    -1 0 
    \strip@pt\dimexpr2\fontdimen1\font\relax\space 1%
  }%
  \box0
  \pdfrestore
  \endgroup
}
\newcommand\Reflectwithslant{\aftergroup\REflectwithslant}
\newcommand\reflectwithslant{\begingroup\afterassignment\Reflectwithslant\setbox0\hbox}
\makeatother

\newcommand\irony{\,\reflectwithslant{?}}

\begin{document}

Roman : Lorem ipsum dolor\irony

Emphasis : \emph{Lorem ipsum dolor\irony}

Bold :  \textbf{Lorem ipsum dolor\irony}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.