Text Formattingusing \pgfmathsetlength to calculate padding; width() function gets wrong answer

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
cypherpunks
Posts: 15
Joined: Sat Dec 10, 2016 12:26 pm

using \pgfmathsetlength to calculate padding; width() function gets wrong answer

Post by cypherpunks »

I have a split 2 column page, one for each language. Using footnotes like normal is a problem because all the footnotes end up below the left column (the french column in this case). Every footnote has a french and english version, so I’ve created a split footnote. The problem is that the padding added to align the footnotes under the right column is not giving expected results.

When there is only one footnote, no problem, because there’s nothing to align. Two or more and we have problems.

Code: Select all

Code, edit and compile here:
\documentclass{scrartcl}
\usepackage[english,french]{babel}
\usepackage{enumerate}
\usepackage{parcolumns} % needed to get two columns without breaking \begin{enumerate}
\usepackage{footmisc} % needed to reuse footnotes with labels & references
\usepackage{pgf} % needed for math calclations
\usepackage{lipsum}
% \bilingual constructs two columns, one for each language, and keeps
% the paragraphs parallel. The “parcolumns” pkg was favored over the
% “parallel” and “paracol” pkgs because /enumerate/ environments are
% possible without messing up the vertical line that divides the two
% columns.
%
% Left col → French
% Right col → English
%
% syntax:
% \bilingual{<French text>}{<English test>}
%
\newcommand{\bilingual}[2]{%
\colchunk{\selectlanguage{french}#1}%
\colchunk{\selectlanguage{english}#2}%
\colplacechunks
}
\newlength{\padding}
% bilingual footnote syntax:
% \bilingualfn{<tag>}{<French text>}{<English test>}
%
% BUG: \pgfmathsetlength does not correctly calculate \padding
\newcommand{\bilingualfn}[3]{%
\addtocounter{footnote}{1}%
\pgfmathsetlength{\padding}{0.5\textwidth-width("#2")}%
\footnotetext{%
\emph{(fr)}~\selectlanguage{french}#2\selectlanguage{english}%
\hspace{\padding}\arabic{footnote}.%
\emph{(en)}~#3\label{#1}}%
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply