1

I use latex command and want to insert a simple ASCII diagram into my .tex file:

                                                         ┌───► Intensity transformation
                        ┌───────────► Spatial            │
                        │    (spatial domain processing)─┤
                        │                                │
                        │                                └───► Spatial Filtering
                        │
                        │
  Image    ───► which ──┤
processing      domain? │
                        │
                        │
                        │
                        │
                        └───────────► Transform
                             (frequency domain processing)

But I get large number of LaTeX Error: Unicode character ... not set up for use with LaTeX. How I can sole the problem without using another typesetting system, for example XeTeX?

  • Please provide a minimal working example (MWE). Does it need to be "ASCII-based"? You could draw this with "real" arrows. If this is to be ASCII (which your diagram is in fact not, since ASCII does not contain arrows), it should be placed in some verbatim environment, I suppose. – Jasper Habicht Mar 12 '23 at 08:44
  • 2
    Well, your "ASCII" diagram is using a lot of non-ASCII characters... :P I guess you'll have to bite the bullet and define all your non-ASCII symbols using \DeclareUnicodeSymbol or similar, take a look here: https://tex.stackexchange.com/a/29462/117050 – Skillmon Mar 12 '23 at 08:44
  • @JasperHabicht I prefer to use ASCII; because I can draw it quickly without need to define node and ... . – hasanghaforian Mar 12 '23 at 09:02
  • 2
    @hasanghaforian calling your diagram ASCII is completely misleading. You get the error due to non ASCII characters with high Unicode code points from the Box Drawing bock. – David Carlisle Mar 12 '23 at 10:42

2 Answers2

8

For example, DejaVu-Mono Unicode font includes desired characters.

I tried it in OpTeX:

\fontfam[DejaVu]
\famvardef\tt{\Dejavu\mono\setff{-liga;-tlig}\rm}

\begtt \typosize[8/10] ┌───► Intensity transformation ┌───────────► Spatial │ │ (spatial domain processing)─┤ │ │ │ └───► Spatial Filtering │ │ Image ───► which ──┤ processing domain? │ │ │ │ │ └───────────► Transform (frequency domain processing) \endtt \bye

The result is as expected:

pseudo-ASCII art

wipet
  • 74,238
  • I could not run your code. Probably you are using abbreviations. – hasanghaforian Mar 12 '23 at 10:53
  • 1
    @hasanghaforian wipet is using optex not latex, and a Unicode font. As I comment in my answer you could get that output by using the same font in lualatex, but you requested an answer using 8-bit fonts. – David Carlisle Mar 12 '23 at 11:01
  • 1
    Yes, I am using abbreviations. It is OpTeX, as I explicitly mentioned in my answer. – wipet Mar 12 '23 at 11:14
  • @wipet I think the user meant "undefined abbreviations" which is why I repeated that this was optex not latex (even though you say that in the answer) (it's my vote that put you on +1 by the way:-) – David Carlisle Mar 12 '23 at 12:08
3

If you had used ASCII characters there would have been no problem.

As it is, you could use (more easily with a unicode tex) a font that supports the Unicode box drawing range, but here more in the spirit of classic tex, I fill in with math characters.

enter image description here

\documentclass{article}

\DeclareUnicodeCharacter{2500}{\makebox[\fontcharwd\fontx][l]{$-$}} \DeclareUnicodeCharacter{2502}{\makebox[\fontcharwd\fontx][l]{$|$}} \DeclareUnicodeCharacter{250C}{\makebox[\fontcharwd\fontx][l]{$\lceil$}} \DeclareUnicodeCharacter{25BA}{\makebox[\fontcharwd\fontx][l]{$\rightarrow$}} \DeclareUnicodeCharacter{2514}{\makebox[\fontcharwd\fontx][l]{$\lfloor$}} \DeclareUnicodeCharacter{2524}{\makebox[\fontcharwd\fontx][c]{\llap{$-$}$|$}} \begin{document} \small \begin{verbatim} ┌───► Intensity transformation ┌───────────► Spatial │ │ (spatial domain processing)─┤ │ │ │ └───► Spatial Filtering │ │ Image ───► which ──┤ processing domain? │ │ │ │ │ └───────────► Transform (frequency domain processing) \end{verbatim} \end{document}

David Carlisle
  • 757,742