4

I don't understand how to get ▼ (U+25BC; filled and inverted triangle) in my XeLaTeX file. The following lines are part of my XeLaTeX which seems relevant to this issue. I wish to modify the file to get ▼ (U+25BC; filled and inverted triangle), but it does not make progress. I suppose many packages are struggling against each other in the file. I would be most grateful if you kindly share some good remedy for this case.

As for your information, I'm using TeXShop version 4.31 (XeLaTeX) based on MacBook Pro. I should use English, Sanskrit, Tibetan, and traditional Chinese letters in this file.

\usepackage{polyglossia, fontspec, xunicode} 
\usepackage[Apara, Bpara,Cpara]{ednotes} 
\usepackage{setspace}
\setmainlanguage{english}
\setotherlanguages{sanskrit}
\usepackage{xeCJK}

\setCJKsansfont[Path=/Users/XXX/Library/Fonts/]{NotoSerifCJK.ttc}

\usepackage{ucs} 
\usepackage[utf8x]{inputenc}
\usepackage{textcomp} 

\DeclareUnicodeCharacter{"2100}{\textcelsius}
\DeclareUnicodeCharacter{"2103}{\textcelsius}
\DeclareUnicodeCharacter{"25BC}{\textcelsius}

%%%%%Sigla and Symbols
\usepackage{enumitem}
\usepackage{setspace}
\usepackage{ltablex}

%%%%%critical_apparatus
\usepackage{bbding}
\usepackage{ulem}
\usepackage{xstring}
\usepackage{ifthen}
\usepackage{wasysym} %This line is related to \astrosun ⊙

\begin{document}

\char "2100\relax

\char "2103\relax

\char "25BC\relax

\end{document}
  • I don't have your font but remove at least ucs and inputenc. – Ulrike Fischer Aug 20 at 18:40
  • You don’t need textcomp if you’re already loading fontspec (through polyglossia, here), either. It’s only for legacy 8-bit fonts. – Davislor Aug 20 at 19:22
  • Why are you declaring "25BC as \textcelsius, which is ℃? – Davislor Aug 20 at 19:26
  • @Ulrike Fischer. Thank you very much for your comment. I'll follow your advice. – Woonsaan Seok Aug 20 at 20:51
5

Here’s a simplified MWE:

\documentclass{standalone}
\usepackage{polyglossia} % Includes fontspec
\usepackage{newunicodechar}

\defaultfontfeatures{Scale=MatchUppercase}

\setmainlanguage{english}
\setotherlanguage{sanskrit}
% \setmainfont, \newfontfamily\devanagarifontsf, \setCJKfont, etc.
% Alternatively, you could use babel.

\newfontfamily\symbolfont{DejaVu Sans Mono}

\newunicodechar{^^^^25bc}{{\symbolfont\symbol{"25BC}}} % ▼

\begin{document}
▼{^^^^25bc}
\end{document}

Black wedge font sample

This uses fontspec (which gets loaded by polyglossia) to set up a symbol font containing the glyph and newunicodechar to switch to that font for that symbol. (If you also wanted to use it in math mode, you would need a more complex command with \ifmmode, but you don’t appear to.)

One problem is, you seem to be pasting code in from a couple of examples that aren’t compatible with each other. For example, you would only use inputenc, \DeclareUnicodeCharacter and textcomp with legacy 7- and 8-bit fonts, not with modern Unicode fonts. I recommend you take out any packages from your preamble that you’re not sure you need.

Another is that \char or \symbol selects the glyph at the given position in the current font. That’s what you want when defining the command in your preamble, but not when using it in your document. You set the character active, so it gets replaced by a command, and want some code that the TeX engine treats as if you had typed the character itself. That’s ^^^^xxxx.

You’re also combining different packages for internationalization, which might or might not work for you. You might try babel with \babelfont to support all four of those languages with a consistent interface.

Multilingual Template

There are two possible answers to the follow-up question in the comments, depending on what you want.

If you’re making something like a symbol dictionary and only need stand-alone glyphs, you probably want the ucharclasses package. That lets you designate a font for your obscure Chinese characters, such as Babelstone Han, another for your astrological symbols, and so on. Then you type a glyph in and XeTeX displays each glyph from the right font automatically.

If you genuinely need to typeset entire words and passages in all four languages, the following preamble lets you do it in babel. It requires XeLaTeX. (The experimental HarfTeX might also work.) I also set up commands and environments named like polyglossia.

\documentclass{article} % Or whatever is appropriate.
% The next line is only to make the output narrower, to fit into an image
% on TeX.SX:  Remove geometry from your document and just give the paper
% size as an option to the document class.
\usepackage[paperwidth=10cm]{geometry}
\usepackage{babel} % You would need the bidi option if using RTL.
\usepackage{newunicodechar} % For \newunicodechar
\usepackage{fontspec} % For \defaultfontfeature

% This allows you to typeset passages in these langauges.  If you only need
% to display individual, stand-alone glyphs, `ucharclasses` is simpler and
% allows you to just type the leeters in as UTF-8.
\babelprovide[import, main, language=Default]{english}
\babelprovide[import]{sanskrit-devanagari}
\babelprovide[import]{chinese-traditional}
\babelprovide[import]{tibetan}

\defaultfontfeatures{Scale=MatchUppercase}
% Set these to your fonts of choice:
\babelfont{rm}
          [Scale=1.0, Ligatures=Common]{Linux Libertine O}
\babelfont{sf}
          [Ligatures=Common]{Linux Biolinum O}
\babelfont[chinese-traditional]{rm}
          [Ligatures={Common, Discretionary}]{Noto Serif CJK TC}
\babelfont[chinese-traditional]{sf}
          {Noto Sans CJK TC}
\babelfont[sanskrit-devanagari]{rm}
          [Language=Default]{Noto Serif Devanagari}
\babelfont[sanskrit-devanagari]{sf}
          [Language=Default]{Noto Sans Devanagari}
\babelfont[tibetan]{rm} 
          [Language=Default]{Noto Sans Tibetan}
\babelfont[tibetan]{sf}
          [Language=Default]{Noto Sans Tibetan}

\newfontfamily\symbolfont{Linux Libertine}

% You might or might not need to set up these symbols specifically.  They
% might just work.
\newunicodechar{^^^^2100}{{\symbolfont\symbol{"2100}}} % ℀
\newunicodechar{^^^^2103}{{\symbolfont\symbol{"2103}}} % ℃
\newunicodechar{^^^^25bc}{{\symbolfont\symbol{"25BC}}} % ▼

\newcommand\textenglish[1]{\foreignlanguage{english}{#1}}
\newcommand\textchinese[1]{\foreignlanguage{chinese-traditional}{#1}}
\newcommand\textsanskrit[1]{\foreignlanguage{sanskrit-devanagari}{#1}}
\newcommand\texttibetan[1]{\foreignlanguage{tibetan}{#1}}

% Enables \begin{chinese}, etc., for full paragraphs in another language.
\newenvironment{english}%
{\begin{otherlanguage}{english}}%
{\end{otherlanguage}}

\newenvironment{chinese}%
{\begin{otherlanguage}{chinese-traditional}}%
{\end{otherlanguage}}

\newenvironment{sanskrit}%
{\begin{otherlanguage}{sanskrit-devanagari}}%
{\end{otherlanguage}}

\newenvironment{tibetan}%
{\begin{otherlanguage}{tibetan}}%
{\end{otherlanguage}}


\begin{document}
This document is in English, \textsanskrit{संस्कृतम्},
\textchinese{繁體字} and \texttibetan{བོད་སྐད་}, brought to you by the symbols
{^^^^2100}, {^^^^2103} and {^^^^25bc}.
\end{document}

Noto fonts sample

The sample used Google’s Noto fonts, which you might need to download.

You might not want to define symbols such as degrees Celsius this way: you probably want it to match the currently-selected font. However, if you do need to patch in a couple of glyphs that your main font doesn’t have, the examples show you how.

I set a few options on the fonts because of their quirks. For example, all the Language=Default options are there to suppress warning messages that the font doesn’t support that specific language. Things like Noto’s Tibetan fonts not supporting the Tibetan language tag and using DFLT instead are harmless and you could just ignore them. If you feel like bothering with stuff like Numbers=OldStyle, the otfinfo command is a good way to check what features a font supports.

Minimizing the MWE

You ask which of those packages you don’t need. You definitely don’t need inputenc or textcomp. Those packages are for legacy 8-bit fonts. You only need polyglossia or xeCJK if not using babel, but you might find xeCJK convenient if you only need one ideographic script. You don’t need to load fontspec in addition to polyglossia, which loads it automatically, and loading it twice runs the risk of an option clash. (If you really want to, load fontspec before, not after.) You probably don’t want ucs or xunicode.

The bbding and wasysym packages both load a symbol font, so you don’t need them if the symbols you use are in Unicode. For example, the comment suggests that wasysym is being loaded for the astrological sun symbol, which is ☉ (U+2609). You could still make the character an alias for the \astrosun symbol from wasysym, but I’d recommend you stick to Unicode if you can. You’ll get correct scaling and be able to copy from your PDF file.

The other packages look more important, but you could try removing one and seeing if anything breaks. If not, it’s probably not actually being used.

  • 1
    I would like to express my deep appreciation for your kind explanation. I become able to use Unicode as well as wasysym symbol with the help of Davislor and Marjin. Unfortunately, I don't understand what I should remove from preamble among many packages. As a novice to this technical machine, I had got a TeX file from my friend and accumulated my options without optimizing. I would be most grateful if you kindly let me know what I have to remove for the aim. Many thanks in advance! – Woonsaan Seok Aug 20 at 20:47
  • @WoonsaanSeok I added an example that uses babel. – Davislor Aug 20 at 23:13
  • I would like to express my deep appreciation for your elaborated explanation. I make a new file at TeXShop/XeLaTeX based on your MWE focused on babel. Unfortunately, the result says (1) Invalid filename 'Linux Libertine'. (2) Package fontspec Error: The font 'Linux Libertine' cannot be found. Furthermore (3) Similar notices for 'Noto Serif Devanagari', 'Noto Sans Devanagari', 'Noto Sans Tibetan' Even though I installed the fonts to my Mac. I hate to bother you, but I would be most grateful if you kindly show some clue to these symptoms. – Woonsaan Seok Aug 21 at 14:45
  • @WoonsaanSeok I can’t test on my system, but on Mac, I believe that XeTeX can’t find fonts unless they’re added to the system Font Book. You could also try loading them by filename. – Davislor Aug 21 at 16:29
  • That is, loading LinLibertine_R.otf and NotoSansDevanagari-Regular.otfmight work, although then you need to set up bold, etc. manually. – Davislor Aug 21 at 16:34
4

First off, avoid xunicode, ucs, inputenc and \DeclareUnicodeCharacter when you use XeLaTeX.

It's quite strange to map U+2100 ACCOUNT OF or U+25BC BLACK DOWN-POINTING TRIANGLE to \textcelsius.

The font Noto Serif CJK includes the glyphs for U+2100 and U+25BC, but these characters do not trigger switching to the CJK font, so such font should be chosen explicitly.

As others mentioned, newunicodechar can do the job:

\documentclass{article}
\usepackage{polyglossia, fontspec}
\usepackage{xeCJK}

\usepackage[Bpara,Cpara]{ednotes}
\usepackage{setspace}

%%%%%Sigla and Symbols
\usepackage{enumitem}
\usepackage{ltablex}

%%%%%critical_apparatus
\usepackage{bbding}
\usepackage{ulem}
\usepackage{xstring}
\usepackage{ifthen}
\usepackage{wasysym} %This line is related to \astrosun ⊙
\usepackage{newunicodechar}

\setmainlanguage{english}
\setotherlanguages{sanskrit}

\setCJKmainfont{NotoSerifCJK}[Path=./,Extension=.ttc]
\newfontfamily{\various}{NotoSerifCJK}[Path=./,Extension=.ttc]

\newunicodechar{℀}{{\various ℀}}
\newunicodechar{▼}{{\various ▼}}

\begin{document}

℀

℃

▼

\end{document}

enter image description here

By the way, it's not possible to set the CJK sans font without setting the main font; also, Noto Serif CJK is not a sans serif font.

Of course, you can use different fonts for the symbols missing from the main font you're using.

  • Thank you very very much for your invaluable suggestions. Unfortunately, I don't understand what I should remove from preamble among many packages. As a novice to this technical machine, I had got a TeX file from my friend and accumulated my options without optimizing as you can guess. I would be most grateful if you kindly let me know what I have to optimize for ``diet." I still want to know how to approach Unicode symbols and special characters which some fonts support when necessary. Many thanks in advance. – Woonsaan Seok Aug 20 at 21:17
0

Since you are already loading wasysym, you could use \DOWNarrow from that package. It is slightly larger than the Unicode character.

MWE, with thanks to Davislor:

\documentclass{standalone}
\usepackage{polyglossia} % Includes fontspec
\usepackage{newunicodechar}
\usepackage{wasysym}

\defaultfontfeatures{Scale=MatchUppercase}

\setmainlanguage{english}
\setotherlanguage{sanskrit}
% \setmainfont, \newfontfamily\devanagarifontsf, \setCJKfont, etc.
% Alternatively, you could use babel.

\newfontfamily\symbolfont{DejaVu Sans Mono}

\newunicodechar{^^^^25bc}{{\symbolfont\symbol{"25BC}}} % ▼

\begin{document}
▼{^^^^25bc}\DOWNarrow
\end{document}

Result:

enter image description here

  • 1
    @Marjin Thank you very much for your explanation. I become able to use both Unicode and \DOWNarrow of wasysym with your kind reply. Thanks again! – Woonsaan Seok Aug 20 at 20:41

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.