weird latex-interpreter problem in annotation when adding one line to table

8 views (last 30 days)
dear experts,
trying to plot the data of a confusion matrix via annotations, i stumbled upon a weird effect and i really haven't any clue what could be the cause for this effect.
a string, containing a latex formated table, is shown via an annotation textbox. in my example code, the upper table works fine. but, when just adding another row of data (e.g. duplicate the 'GHI' row), results in an Warning: Error updating TextBox.
what am is missing???
%% example
clear all; close all;
%% this works fine
figure()
subplot(2,1,1); axis off;
strA = ['\begin{tabular}{lrllllllllll} \hline '...
' & & \multicolumn{10}{c}{\textbf{response}} \\ \cline{3-12} '...
' & & \multicolumn{2}{c}{\textbf{ABC}} & \multicolumn{2}{c}{\textbf{DEF}} & \multicolumn{2}{c}{\textbf{GHI}} & \multicolumn{2}{c}{\textbf{KLM}} & \multicolumn{2}{c}{\textbf{total}} \\ '...
' & & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} \\ \hline '...
'\multicolumn{1}{c}{\textbf{target}} & \textbf{ABC} & 205 & 89.9 & 6 & 2.6 & 1 & 0.4 & 16 & 7.0 & 228 & 25 \\ '...
'\textbf{} & \textbf{DEF} & 40 & 17.5 & 175 & 76.8 & 11 & 4.8 & 2 & 0.9 & 228 & 25 \\ '...
'\textbf{} & \textbf{GHI} & 9 & 3.9 & 4 & 1.8 & 202 & 88.6 & 13 & 5.7 & 228 & 25 \\ '...
'\textbf{} & \textbf{KLM} & 10 & 4.4 & 0 & 0 & 11 & 4.8 & 207 & 90.8 & 228 & 25 \\ '...
'\end{tabular}'];
ha = annotation('textbox',[0 0.5 1 0.5],...
'EdgeColor', 'none',...
'HorizontalAlignment','center',...
'VerticalAlignment','middle',...
'Interpreter', 'latex');
set(ha, 'String', strA);
%% NOW: just add copy one of the last four data-lines!!!
subplot(2,1,2); axis off;
strB = ['\begin{tabular}{lrllllllllll} \hline '...
' & & \multicolumn{10}{c}{\textbf{response}} \\ \cline{3-12} '...
' & & \multicolumn{2}{c}{\textbf{ABC}} & \multicolumn{2}{c}{\textbf{DEF}} & \multicolumn{2}{c}{\textbf{GHI}} & \multicolumn{2}{c}{\textbf{KLM}} & \multicolumn{2}{c}{\textbf{total}} \\ '...
' & & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} & \multicolumn{1}{c}{No.} & \multicolumn{1}{c}{\%} \\ \hline '...
'\multicolumn{1}{c}{\textbf{target}} & \textbf{ABC} & 205 & 89.9 & 6 & 2.6 & 1 & 0.4 & 16 & 7.0 & 228 & 25 \\ '...
'\textbf{} & \textbf{DEF} & 40 & 17.5 & 175 & 76.8 & 11 & 4.8 & 2 & 0.9 & 228 & 25 \\ '...
'\textbf{} & \textbf{GHI} & 9 & 3.9 & 4 & 1.8 & 202 & 88.6 & 13 & 5.7 & 228 & 25 \\ '...
'\textbf{} & \textbf{GHI} & 9 & 3.9 & 4 & 1.8 & 202 & 88.6 & 13 & 5.7 & 228 & 25 \\ '...
'\textbf{} & \textbf{KLM} & 10 & 4.4 & 0 & 0 & 11 & 4.8 & 207 & 90.8 & 228 & 25 \\ '...
'\end{tabular}'];
ha = annotation('textbox',[0 0 1 0.5],...
'EdgeColor', 'none',...
'HorizontalAlignment','center',...
'VerticalAlignment','middle',...
'Interpreter', 'latex');
set(ha, 'String', strB);
thanks in advance,
adam

Accepted Answer

Andreas Apostolatos
Andreas Apostolatos on 12 Nov 2021
Hello everyone,
This post is already a little bit old, but I would like to provide with some information in case somebody else stumbles upon the same issue.
The issue in this case appears to lie in the dynamic memory that is handed to TeX for creating the table, which is not sufficient for larger tables. This oftentimes results in the error "TeX capacity exceeded", which indicates the fact that TeX would need additional dynamic memory to perform the table layout.
The only workaround in this case is to split up the table into smaller tables and stack them together. This way the TeX layout does not have to work on the entire table at once and thus the issue should no longer persist.
I hope that this information helps.
Kind regards,
Andreas

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!