General ⇒ Is the command loaded?
Is the command loaded?
Is it possible to write a check for things like this in the tex code?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Is the command loaded?
Code: Select all
\documentclass{article}
\usepackage[czech,magyar,french,spanish,english]{babel}
\makeatletter
\newcommand{\IsFrenchspacingOn}{\ifnum\the\sfcode`\.=\@m Yes \else No \fi}
\makeatother
\begin{document}
Is french spacing on?
English: \IsFrenchspacingOn
\selectlanguage{spanish}
Spanish: \IsFrenchspacingOn
\selectlanguage{french}
French: \IsFrenchspacingOn
\selectlanguage{magyar}
Magyar: \IsFrenchspacingOn
\selectlanguage{czech}
Czech: \IsFrenchspacingOn
\end{document}
Re: Is the command loaded?
Could you explain the "\the\sfcode`\.=\@m" condition?
Actually I don't know how to programme macros in latex. I was googling for some answers, but I couldn't find so much information about it. Could you recommend some material about programming latex?
Thanks, Máté
Is the command loaded?
Let me explain how I arrived to the above code, since that will answer your first question and will give some hints about the second. I first opened the doc of babel. It is in your hard disk: type "texdoc babel" in the command line or search in somewhere like /usr/local/texlive/2008/texmf-dist/doc/generic/babel; if not, look here. I went to the magyar section and searched "frenchspacing". This directed me to an instance of "frenchspacing"... in the Czech language. There I learned that languages activate or deactivate frenchspacing through the \bbl@frenchspacing command. So I searched it. This command appears in Section 12.6, defined as follows:zaradek wrote: Could you explain the "\the\sfcode`\.=\@m" condition?
Actually I don't know how to programme macros in latex. I was googling for some answers, but I couldn't find so much information about it. Could you recommend some material about programming latex?
Code: Select all
\def\bbl@frenchspacing{%
\ifnum\the\sfcode‘\.=\@m
\let\bbl@nonfrenchspacing\relax
\else
\frenchspacing
\let\bbl@nonfrenchspacing\nonfrenchspacing
\fi}
At first, I didn't understand the \sfcode and \@m commands. I searched them in a good book on Plain TeX. In addition to the TeX book, by D. Knuth, there exists the excellent manual TeX by Topic, by Victor Eijkhout, freely downloadable. The \@m macro is just an internal abbreviation of 1000. The \sfcode of a character is a number related with the amount of space that TeX should leave after it. The sfcode of punctuation signs is 1000, if frenchspacing is active, and greater otherwise. So the trick, in your problem, consists in testing if the sfcode of . (point) is 1000 or not.
In different posts, I've cited more resources to learn programming LaTeX (here and here, for example). The moderators and other contributors also often do so. Read their posts, you'll learn a lot!
Re: Is the command loaded?
