I have written a personal command called \compo
that allows you to place a figure next to a text: \compo[.4]{ text }{ figure };
When the figure is created with the tikz calc library, there is this error:
! Package tikz Error: + or - expected.
I installed the tikz babel library
and also used \shorthandoff
and \shortandon
commands, but that doesn't change anything. I guess the problem is my macro.
His code is as follows:
%----------------------------------------
% new command \compo to place a figure next to a text
%----------------------------------------
\newlength{\colG}\newlength{\colD}
\newcommand{\compo}[3][0.5]{
\setlength{\colG}{#1\linewidth}
\setlength{\colD}{\linewidth}%
\addtolength{\colD}{-\colG}
\addtolength{\colG}{-10pt}
\addtolength{\colD}{-10pt}%
\par \noindent%
\begin{minipage}[t]{\colG}\vspace{0cm}#2\end{minipage}\hfill\vrule\hfill%
\begin{minipage}[t]{\colD}\vspace{0cm}#3\end{minipage}\par}
Here is a MCE:
\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{babel}
%----------------------------------------
% new command \compo to place a figure next to a text
%----------------------------------------
\newlength{\colG}\newlength{\colD}
\newcommand{\compo}[3][0.5]{
\setlength{\colG}{#1\linewidth}
\setlength{\colD}{\linewidth}%
\addtolength{\colD}{-\colG}
\addtolength{\colG}{-10pt}
\addtolength{\colD}{-10pt}%
\par \noindent%
\begin{minipage}[t]{\colG}\vspace{0cm}#2\end{minipage}\hfill\vrule\hfill%
\begin{minipage}[t]{\colD}\vspace{0cm}#3\end{minipage}\par}
\begin{document}
\compo[.5]{
Un triangle
}{
\shorthandoff{!:}
\begin{tikzpicture}[handle active characters in code]
\draw(-1,-1) rectangle (4,4);
\coordinate (B) at (0,0);
\coordinate (C) at (3,0);
\coordinate(D) at (2,0);
\draw(B)--(C)--(D)--cycle;
\coordinate (Ap) at ($(C)!.35!-90:(B)$);
\draw (Ap)--(B)--(C)--cycle;
\end{tikzpicture}
\shorthandon{!:}
}
\end{document}
What is the error in the code of this macro \compo
? How do I correct this error?