Tag Info

Hot answers tagged

14

The \ifcase has the syntax \ifcase number zero case\or one\or two\or ...\fi The "number" have to be separated from "zero case". The natural separator is space, but there are formats of the "number" where the "number" is compact (for example from \countdef of \chardef and the additional space gets the part of "zero case". You can try: ...


14

The problem has been examined under a different point of view in Is a command with an argument before and after the command possible? but the situation is different: the object that was to be placed before or after the main command is itself a macro. It's not possible to have a macro that “looks backwards”. TeX is strictly “first in, first out”, after macro ...


12

This answer does not apply to newer TeX engines, such as XeTeX and LuaTeX. By default, these will not treat -- as anything other than --. fontspec can emulate the traditional engines' behaviour. These are, as Tobi pointed out, implemented as ligatures just like fi, fl etc. More specifically, the TeX Font Metric file (which just is a font as far as TeX is ...


11

\documentclass{article} \makeatletter \newcommand{\replaceBS}[2]{{\escapechar=`/ \xdef#2{\expandafter\zap@space\detokenize\expandafter{#1} \@empty}}} \makeatother \begin{document} \def\WindowsFilename{c:\files\examples\pictures\myfile.png} \replaceBS{\WindowsFilename}{\TeXFilename} Current result: \texttt{\TeXFilename} Expected result: ...


10

working backwards: {\uccode‘1=‘i \uccode‘2=‘f \uppercase{\gdef\if@12{}}} % ‘if’ required \uppercase works on tokens and any token other than a character token is left unchanged. Character tokens produce new character tokens with the same catcode as before but with character code obtained by looking up the uccode (if that is non zero) so \gdef uppercases ...


10

The answer given by @wipet explains the need to separate the evaluation of the number after \ifcase from the material that is used if that result is zero and it explains why both "space" or \relax can be wrong depending on the input. As far as LaTeX is concerned: when LaTeX was initially written every byte did count so we dropped any explicit separation ...


10

\vskip is not a macro, but a TeX primitive and it has a different syntax than macros with arguments. The syntax is \vskip<glue specification> where <glue specification> can basically be a skip register or an explicit glue such as \vskip 1pt plus 2pt minus 1pt See the TeXbook or TeX by Topic for more information. On the other hand, the ...


9

Nice example. This is actually not really a TeX bug or anything but a design approach (or rather some uptimization to keep computing expense low --- remember when TeX was designed) in the paragraph breaking algorithm. In a nutshell TeX keeps looking at breakpoints in a paragraph starting at the beginning and working towards the end. In this manner it ...


9

You have \def\tocaldate[#1-#2-#3 #4:#5]{% so there has to be a space token after #3 Fromdate: \fromcaldate[\the\year-\the\month-\the\day 13:00] there is no space token before 13 in the above as the space in the file is absorbed while tokenising \day. Use Fromdate: \fromcaldate[\the\year-\the\month-{\the\day} 13:00]


8

I add three things to the @cfr answer. These TeX-ligature-features are possible in XeTeX and LuaTeX too. First, they are able to load classic TFMs and this feature is native here. Second, they implements this feature as a special font feature in their OTF font loader. This feature is activated differently in both engines: by mapping=tex-text in XeTeX and ...


8

TeX has the \read and \write primitives for reading and writing to files plus of course \input for inputting an entire file 'here'. If you look at for example the LaTeX cross-ref mechanism is uses \write but avoids using \read (line-by-line) in favour of making use of \input with appropriately designed secondary files. As \input is easy enough to ...


8

Your requirement is possible for example with encTeX. Try the following code compiled by csplain format: \mubyte \phantomcmd #1 {\endmubyte \mubytein=0 \def\phantomcmd#1\mycmd#2{1=#1, 2=#2} \def\mycmd{my} \def\normalcmd#1{normal=#1} \mubytein=1 \normalcmd{hello} % gives: normal=hello ...{foo}\mycmd{bar} % gives: ...1=foo, 2=bar \bye When ...


6

In a comment made by the OP, mention was made that the application was one of predetermining quotes prior to a calligraphic letter. As I said in my comment reply, perhaps there is some hope if the problem can be more constrained. For example, if <arg1> is always (and only) a single glyph from a limited set of catcode 12 possibilities, then you could ...


5

You can use the testhyphens package. \documentclass{article} \usepackage[british,welsh]{babel} \usepackage{testhyphens} \begin{document} \begin{checkhyphens}{} un casgliad credadwy traddodiadau athroniaeth mathemateg canolfan hapusrwydd blwyddyn deuddeg llongyfarchiadau cyfeiriadau \end{checkhyphens} \selectlanguage{british} \begin{checkhyphens}{} un ...


5

An explicit number can be expanded without changing it and the unwanted command sequence can be redefined to vanish itself, when expanded: % Setup \makeatletter \newif\ifintheway \def\@citeb{foobar} \def\bfoobar{\inthewayfalse 17} % Extract the number from \csname b\@citeb\endcsname % and store it in the macro \mynumber \begingroup ...


5

Saying \newif\iffoo generates the following list of tokens: \count@\escapechar \escapechar\m@ne \expandafter\expandafter\expandafter\def\@if\iffoo{true}{\let\iffoo=\iftrue} \expandafter\expandafter\expandafter\def\@if\iffoo{false}{\let\iffoo=\iffalse} \@if\iffoo{false} \escapechar\count@ In what follows, spaces (or newlines) are added just for separating ...


5

As far as I know, both MiKTeX and TeX Live for Windows accept paths where \ is replaced by /, so if you define your \WindowsFilename as c:/files/examples/pictures/myfile.png to begin with, you shouldn't have any problem. However, I understand that the casual user might not know this and be used to DOS style paths. If you don't plan to define the paths ...


5

You can't really do it unless you grab the token list you need as an argument. Here's a possibility using environ; usage of expl3 is not necessary, but it provides a good framework for doing the desired job later. \documentclass{article} \usepackage{environ,expl3} \ExplSyntaxOn \NewEnviron{collectitems} { % clear the sequence \seq_clear:N ...


4

Another special issue when dealing with cross references via external file is the order of reading, opening, writing and closing this file. The basic scheme is: \newwrite\fileout % allocations of the file number \def... ... all macros which can be used in the file must be defined \input file ... input only when file exists (the file doesn't exist at ...


4

here's an adaptation of your file that will generate the hyphenations you seek: \documentclass[welsh]{article} \usepackage{babel} \begin{document} \showhyphens{un casgliad credadwy traddodiadau athroniaeth} \showhyphens{mathemateg canolfan hapusrwydd blwyddyn} \showhyphens{deuddeg llongyfarchiadau cyfeiriadau} \end{document} just process this with ...


3

Assuming you are using a plain-like format with the babel hyphenation patterns available (so say pdftex or xetex) you can switch to the correct hyphenation using the fact that \lang@<name> is the language number. Thus \language\csname lang@welsh\endcsname \showhyphens{un casgliad credadwy traddodiadau athroniaeth mathemateg canolfan hapusrwydd ...


3

Is something like this what you want? \documentclass{article} \newenvironment{someenv}{\par\centering}{\par} \newenvironment{XX}{\endXX\bfseries\itshape Do sth with\ }{\mdseries\upshape\par} \let\notXX\endXX \def\abc{ABC} \begin{document} before \begin{someenv} \XX xyz \XX abc \XX \abc \notXX not under \verb|\XX| control % USE \notXX TO FORCE ...


3

I'm not sure you want alignment to the equals signs. But here it is: \documentclass[10pt]{amsart} \usepackage{systeme,mathtools} \begin{document} \begin{align*} \systeme{ -3x-6y=\mathrlap{-15}, 3x+4y=\mathrlap{6} } \\ \systeme{ -3x-6y=\mathrlap{-15}, -2y=\mathrlap{-9} } \\ \systeme{ x+2y=\mathrlap{5}, y=\mathrlap{9/2} } \\ \systeme*{% no alignment on the ...


2

The Knuth's macro \newif is very cryptic. I spent full page 402 in my "TeXbook naruby" with explanation of this. But we can ask if there isn't more straightforward and more understandable solution of this task with equivalent result. I mean that it exists. For example: \def\newif#1{\expandafter\newifA\string#1\relax#1} \edef\tmp{\string\if} ...


1

You can use the code from Macro parameter delimited by more than one delimiter. This code defines the \seplist macro. Its argument is the list of separators. The separators in your example are \XX or \end (with space before this). The definition of \XX looks like: \def\XXa#1{... macro with normal #1 parameter\par\sepused} \def\XX{\seplist{{ \XX}{ ...



Only top voted, non community-wiki answers of a minimum length are eligible