2

A demonstration of the problem by way of a minimal working example

I saved the following LaTeX code in the file ~/Test.tex.

\documentclass{article}
\usepackage{ifthen}
\begin{document}
\the\textdir =%
\ifthenelse{\equal{\the\textdir}{TLT}}{TLT}{TRT}
\end{document}

The code prints out the content of the LuaTeX primitive \textdir register, an equality symbol, and then the string TLT if the contents of said register is TLT, and TRT otherwise.

I then executed the following commands in the Terminal.

> cd ~
> lualatex Test

As a consequence the file ~/Test.pdf was created. When opened in a PDF viewer, it showed "TLT=TRT".


Questions

  1. If \the\textdir expands to the string "TLT", why, then, does the conditional evaluate to the else case "TRT"?

  2. How can I query the value of the \textdir register?

4
  • 2
    same as \jobname and \string it returns catcode 12 characters not catcode 11 Commented Dec 31, 2022 at 11:28
  • @DavidCarlisle So how can I test the value of this register?
    – Evan Aad
    Commented Dec 31, 2022 at 11:29
  • 2
    Look at tex.stackexchange.com/a/638420/4427 for a different strategy, where \xifthenelse{\streqtest{\the\textdir}{TLT}}{True}{False} will work (and, as a bonus, is fully expandable).
    – egreg
    Commented Dec 31, 2022 at 11:41
  • @egreg Actually, in my real-life code (as opposed to the minimal working example listed above) \xifthenelse causes a compilation failure, whereas \ifthenelse works smoothely.
    – Evan Aad
    Commented Dec 31, 2022 at 11:54

1 Answer 1

4

It is the same as \jobname and \string, it returns catcode 12 characters not catcode 11

\documentclass{article}
\usepackage{ifthen}
\begin{document}
\the\textdir =%
\ifthenelse{\equal{\the\textdir}{\detokenize{TLT}}}{TLT}{TRT}
\end{document}

You must log in to answer this question.

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