Снова TeXникам вопрос (в белом венчике из роз)

mtk79

Скажите, пж, а можно в ТеХе возвращать присвоенные значения переменных в преамбуле и производить с ними арифметические операции, как в обычном языке программирования, присвоив новой переменной полученный результат и использовать результат как единицу длины
Пример: допустим, ширина текста текста Хcm
Я задаю абзацный отступ \parindent=Ycm
и хочу использовать величину Z=(X-Y)cm для некоторой процедуры, например, для создания таблицы о две колонки с шириной Y и X-Y соответственно:
\begin{tabular}{m{Xcm} | m{Zcm}}

dunkel68

Кратко: можно
TEX gives us primitive operations to perform arithmetic on registers as follows:
 addition and subtraction on all types of quantities without restrictions;
 multiplication and division by an integer can be performed on a register of
any type;
 multiplication by a real number (i.e., a number with a fractional part) can be
performed on a register of any type, but the stretch and shrink components
of a glue quantity are discarded.
The calc package uses these TEX primitives but provides a more user-friendly
notation for expressing the arithmetic.
An expression is formed of numerical quantities (such as explicit constants and
LATEX counters and length commands) and binary operators (the tokens `+', `-',
`*', and `/' with their usual meaning) using the familiar in x notation; parentheses
may be used to override the usual precedences (that multiplication/division have
higher precedence than addition/subtraction).
Expressions must be properly typed. This means, e.g., that a dimen expression
must be a sum of dimen terms: i.e., you cannot say `2cm+4' but `2cm+4pt' is valid.
In a dimen term, the dimension part must come rst; the same holds for glue
terms. Also, multiplication and division by non-integer quantities require a special
syntax; see below.
Evaluation of subexpressions at the same level of precedence proceeds from left
to right. Consider a dimen term such as \4cm*3*4". First, the value of the factor
4cm is assigned to a dimen register, then this register is multiplied by 3 (using
\multiply and, nally, the register is multiplied by 4 (again using \multiply).
This also explains why the dimension part (i.e., the part with the unit designation)
must come rst; TEX simply doesn't allow untyped constants to be assigned to a
dimen register.
The calc package also allows multiplication and division by real numbers.
However, a special syntax is required: you must use \real{hdecimal constanti}
2
or \ratio{hdimen expressioni}{hdimen expressioni} to denote a real value to be
used for multiplication/division. The rst form has the obvious meaning, and
the second form denotes the number obtained by dividing the value of the rst
expression by the value of the second expression.

mtk79

спасибо.
(правда, как присвоить результату вычислений какую-то букву, переменную или команду я все равно не понял)
но, похоже, проще со всем этим не гемориться и выравнивать вручную уже в итоговой верстке
Оставить комментарий
Имя или ник:
Комментарий: