wolffd@0: function aout = rep_utils(action,fmt,fid) wolffd@0: wolffd@0: %REP_UTILS Utilities for print reports and report elements. wolffd@0: % wolffd@0: % aout = rep_utils(action,fmt,[fid]) wolffd@0: % wolffd@0: % Input and output arguments ([]'s are optional): wolffd@0: % action (string) action identifier wolffd@0: % (cell array) {action,par1,par2,...} wolffd@0: % the action identifier, followed by action wolffd@0: % parameters wolffd@0: % [fmt] (string) format of output, 'txt' by default wolffd@0: % [fid] (scalar) output file id, by default NaN in which wolffd@0: % case output is not written, only returned wolffd@0: % in aout wolffd@0: % wolffd@0: % aout (varies) output of the action wolffd@0: % wolffd@0: % Here are the actions and their arguments: wolffd@0: % 'printlines' par1 (cellstr) print par1, each cell on a new line wolffd@0: % 'header' par1 (string) print document header using par1 as title wolffd@0: % 'footer' print document footer wolffd@0: % 'compile' par1 (string) compile the named document (only 'ps' and 'pdf') wolffd@0: % 'inserttable' par1 (struct) print given table wolffd@0: % par2 (scalar) print lines between rows if par2=1 wolffd@0: % par3 (scalar) use longtable format (only 'ps' and 'pdf') wolffd@0: % 'printfigure' par1 (string) print current figure to file, par1 = filename wolffd@0: % par2 (scalar) used resolution (150 dpi by default) wolffd@0: % par3 (scalar) if par3=1, insert figure in minipage wolffd@0: % 'insertfigure' par1 (string) insert figure to report, par1 = filename of figure wolffd@0: % par2 (vector) size 2 x 1, size of figure relative to page size wolffd@0: % NaN = automatic scaling wolffd@0: % par3 (scalar) if par3=1, insert figure in minipage (only 'ps' and 'pdf') wolffd@0: % 'insertbreak' insert paragraph break into report wolffd@0: % wolffd@0: % See also REP_STATS. wolffd@0: wolffd@0: % Contributed to SOM Toolbox 2.0, January 2nd, 2002 by Juha Vesanto wolffd@0: % Copyright (c) by Juha Vesanto wolffd@0: % http://www.cis.hut.fi/projects/somtoolbox/ wolffd@0: wolffd@0: % Version 2.0beta juuso 020102 wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: %% input arguments wolffd@0: wolffd@0: pars = {''}; wolffd@0: if iscell(action), wolffd@0: if length(action)>1, pars = action(2:end); end wolffd@0: action = action{1}; wolffd@0: end wolffd@0: wolffd@0: if nargin<2 | isempty(fmt), fmt = 'txt'; end wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: REPORT_OUTPUT_FMT = fmt; wolffd@0: wolffd@0: if nargin<3 | isempty(fid), fid = NaN; end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: %% action wolffd@0: wolffd@0: aout = []; wolffd@0: printable = 0; wolffd@0: wolffd@0: switch action, wolffd@0: case 'printlines', wolffd@0: aout = pars{1}; wolffd@0: case 'header', wolffd@0: switch fmt, wolffd@0: case {'ps','pdf'}, aout = tex_startdocument(pars{1}); wolffd@0: case 'html', aout = html_startpage(pars{1}); wolffd@0: case 'txt', aout = cell(0); wolffd@0: end wolffd@0: printable = 1; wolffd@0: case 'footer', wolffd@0: switch fmt, wolffd@0: case {'ps','pdf'}, aout = tex_enddocument; wolffd@0: case 'html', aout = html_endpage; wolffd@0: case 'txt', aout = cell(0); wolffd@0: end wolffd@0: printable = 1; wolffd@0: case 'compile', aout = compiledocument(pars{1}); wolffd@0: case 'inserttable', aout = inserttable(pars{:}); printable = 1; wolffd@0: case 'printfigure', printfigure(pars{:}); wolffd@0: case 'insertfigure', aout = insertfigure(pars{:}); printable = 1; wolffd@0: case 'insertbreak', aout = insertbreak; printable = 1; wolffd@0: case 'joinstr', aout = joinstr(pars{:}); printable = 1; wolffd@0: case 'rulestr', aout = rulestr(pars{:}); printable = 1; wolffd@0: case 'c_and_p_str', aout = c_and_p_str(pars{:}); printable = 1; wolffd@0: case 'p_str', aout = p_str(pars{:}); printable = 1; wolffd@0: end wolffd@0: wolffd@0: % if output file is given, print lines wolffd@0: if ~isnan(fid) & printable, wolffd@0: if ~iscell(aout), aout = {aout}; end wolffd@0: for i = 1:length(aout), fprintf(fid,'%s\n',fmtline(aout{i})); end wolffd@0: end wolffd@0: wolffd@0: return; wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: %% subfunctions wolffd@0: wolffd@0: %% simple formatter strings wolffd@0: wolffd@0: function s = joinstr(cs, sep1, sep2) wolffd@0: if nargin==1, sep1 = ', '; sep2 = ' and '; end wolffd@0: if nargin<3, sep2 = sep1; end wolffd@0: if isempty(cs), wolffd@0: s = ''; wolffd@0: elseif strcmp(sep1,'\n'), wolffd@0: if size(cs,1)==1, cs = cs'; end wolffd@0: s = char(cs); wolffd@0: else wolffd@0: s = cs{1}; wolffd@0: for i=2:length(cs)-1, s = [s sep1 cs{i}]; end wolffd@0: if length(cs)>1, s = [s sep2 cs{end}]; end wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function str = c_and_p_str(n,m) wolffd@0: wolffd@0: % return a string of form # (%), e.g. '23 (12%)' wolffd@0: if n==m, p = '100'; wolffd@0: elseif n==0, p = '0'; wolffd@0: else p = sprintf('%.2g',100*n/m); wolffd@0: end wolffd@0: str = sprintf('%d (%s%%)',round(n),p); wolffd@0: return; wolffd@0: wolffd@0: function str = p_str(p) wolffd@0: % return a string of form %, e.g. '12%' wolffd@0: if round(p*100)>=100, p = sprintf('%3g',100*p); wolffd@0: elseif abs(p)=','inf',' ','<',''); wolffd@0: end wolffd@0: nr = length(sR); wolffd@0: cs = cell(nr,1); wolffd@0: fmt = '%.2g'; wolffd@0: if nargin<2, cnames = {sR.name}; end wolffd@0: if isempty(cnames), cnames = cell(nr,1); cnames(:) = {''}; end wolffd@0: for i=1:nr, wolffd@0: low = sR(i).low; wolffd@0: high = sR(i).high; wolffd@0: switch isfinite(low) + 2*isfinite(high), wolffd@0: case 0, cs{i} = [cnames{i} ' ' 'any']; wolffd@0: case 1, cs{i} = [cnames{i} ' ' m geq sprintf(fmt,low) m]; wolffd@0: case 2, cs{i} = [cnames{i} ' ' m less sprintf(fmt,high) m]; wolffd@0: case 3, cs{i} = [cnames{i} ' ' m in '[' sprintf(fmt,low) ',' sprintf(fmt,high) ']' m]; wolffd@0: end wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: %% print figure wolffd@0: wolffd@0: function imgfmt = fmt2imgfmt wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case 'ps', imgfmt = 'ps'; wolffd@0: case 'pdf', imgfmt = 'pdf'; wolffd@0: case 'html', imgfmt = 'png'; wolffd@0: case 'txt', imgfmt = ''; wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function printfigure(fname,resolution) wolffd@0: if nargin<2, resolution = 150; end wolffd@0: fnameps = [fname '.ps']; wolffd@0: switch fmt2imgfmt, wolffd@0: case 'ps', wolffd@0: print('-dpsc2',fnameps); wolffd@0: case 'pdf', wolffd@0: print('-dpsc2',fnameps); wolffd@0: eval(sprintf('!ps2pdf %s',fnameps)); wolffd@0: case 'gif', wolffd@0: print('-dpsc2',fnameps); wolffd@0: cmd = 'pstogif'; wolffd@0: opt = sprintf('-depth 1 -density %d',resolution); wolffd@0: unix(sprintf('%s %s -out %s %s',cmd,opt,[fname '.gif'],fnameps)); wolffd@0: case 'png', wolffd@0: opt = sprintf('-r%d',resolution); wolffd@0: print('-dpng',opt,[fname '.png']); wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: %% headers and footers, and compilation wolffd@0: wolffd@0: function cs = tex_startdocument(title) wolffd@0: % tex document headers wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: cs = cell(0); wolffd@0: cs{end+1} = '\documentclass[10pt,a4paper]{article}'; wolffd@0: cs{end+1} = '\usepackage[dvips]{epsfig,graphicx,color}'; wolffd@0: cs{end+1} = '\usepackage{float,graphics,subfigure}'; wolffd@0: cs{end+1} = '\usepackage{multirow,rotating,portland,lscape,longtable,pifont}'; wolffd@0: cs{end+1} = '\usepackage[T1]{fontenc}'; wolffd@0: if strcmp(REPORT_OUTPUT_FMT,'pdf'), cs{end+1} = '\usepackage{pslatex}'; end wolffd@0: cs{end+1} = '\usepackage[english]{babel}'; wolffd@0: wolffd@0: cs{end+1} = '\oddsidemargin 0 mm'; wolffd@0: cs{end+1} = '\evensidemargin 0 mm'; wolffd@0: cs{end+1} = '\textwidth 17 cm'; wolffd@0: cs{end+1} = '\topmargin 0 mm'; wolffd@0: cs{end+1} = '\textheight 21 cm'; wolffd@0: cs{end+1} = '\voffset 0 mm'; wolffd@0: wolffd@0: cs{end+1} = '\begin{document}'; wolffd@0: cs{end+1} = ['\title{' title '}']; wolffd@0: cs{end+1} = '\maketitle'; wolffd@0: %cs{end+1} = '\tableofcontents'; wolffd@0: %cs{end+1} = '\clearpage'; wolffd@0: return; wolffd@0: wolffd@0: function cs = tex_enddocument wolffd@0: cs = cell(0); wolffd@0: cs{end+1} = '\end{document}'; wolffd@0: return; wolffd@0: wolffd@0: function cs = html_startpage(title) wolffd@0: % print HTML document headers wolffd@0: cs = cell(0); wolffd@0: cs{end+1} = ''; wolffd@0: cs{end+1} = ''; wolffd@0: cs{end+1} = ''; wolffd@0: cs{end+1} = sprintf(' %s',title); wolffd@0: cs{end+1} = ''; wolffd@0: cs{end+1} = ''; wolffd@0: if ~isempty(title), cs{end+1} = sprintf('

%s

',title); end wolffd@0: return; wolffd@0: wolffd@0: function cs = html_endpage wolffd@0: % print HTML document footers wolffd@0: cs = cell(0); wolffd@0: cs{end+1} = '


'; wolffd@0: cs{end+1} = ''; wolffd@0: cs{end+1} = ''; wolffd@0: return; wolffd@0: wolffd@0: function files = compiledocument(filename) wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case 'pdf', wolffd@0: eval(sprintf('!pdflatex --interaction batchmode %s.tex',filename)); wolffd@0: eval(sprintf('!pdflatex --interaction batchmode %s.tex',filename)); wolffd@0: %eval(sprintf('!acroread %s.pdf &',filename)); wolffd@0: files = {[filename '.aux'],[filename '.log'],[filename '.out'],[filename '.pdf']}; wolffd@0: case 'ps', wolffd@0: eval(sprintf('!latex --interaction batchmode %s.tex',filename)); wolffd@0: eval(sprintf('!latex --interaction batchmode %s.tex',filename)); wolffd@0: eval(sprintf('!dvips %s.dvi',filename)); wolffd@0: eval(sprintf('!ps2pdf %s.ps',filename)); wolffd@0: %eval(sprintf('!ghostview %s.ps &',filename)); wolffd@0: files = {[filename '.aux'],[filename '.log'],[filename '.out'],[filename '.dvi'],[filename '.pdf']}; wolffd@0: case 'html', wolffd@0: case 'txt', wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: wolffd@0: function vstr = defaultformat(val) wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if ischar(val), vstr = val; wolffd@0: elseif iscellstr(val), vstr = char(val); wolffd@0: elseif isempty(val), vstr = ''; wolffd@0: elseif isnumeric(val), wolffd@0: if val==round(val), fmt = '%d'; else fmt = '%.3g'; end wolffd@0: if abs(val)<=eps, vstr = '0'; else vstr = sprintf(fmt,val); end wolffd@0: elseif isstruct(val) & isfield(val,'values') & isfield(val,'headers'), wolffd@0: % a table wolffd@0: vstr = joinstr(inserttable(val,0),'\n'); wolffd@0: if any(strcmp(REPORT_OUTPUT_FMT,{'ps','pdf'})), wolffd@0: vstr= inserttominipage(vstr); wolffd@0: end wolffd@0: else wolffd@0: vstr = ''; fprintf(1,'defaultformat unable to handle input\n'); wolffd@0: whos val wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: %% report elements (list, table, image, link) wolffd@0: wolffd@0: function str = fmtline(str) wolffd@0: % replace some formatting elements depeding on output format wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if isempty(str), str = ''; return; end wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case {'ps','pdf'}, wolffd@0: str = strrep(str,'', '{\bf '); wolffd@0: str = strrep(str,'', '{\em '); wolffd@0: str = strrep(str,'', '{\tt '); wolffd@0: str = strrep(str,'', '}'); wolffd@0: str = strrep(str,'', '}'); wolffd@0: str = strrep(str,'','}'); wolffd@0: str = strrep(str,'#','\#'); wolffd@0: str = strrep(str,'%','\%'); wolffd@0: case 'html', % nil wolffd@0: case 'txt', wolffd@0: str = strrep(str,'', '*'); wolffd@0: str = strrep(str,'', '*'); wolffd@0: str = strrep(str,'', ''); wolffd@0: str = strrep(str,'', '*'); wolffd@0: str = strrep(str,'', '*'); wolffd@0: str = strrep(str,'',''); wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function cs = insertbreak wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: cs = cell(0); wolffd@0: switch REPORT_OUTPUT_FMT wolffd@0: case {'ps','pdf'}, cs{end+1} = ''; wolffd@0: case 'html', cs{end+1} = '

'; wolffd@0: case 'txt', cs{end+1} = ''; wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function insertlist(list,enum) wolffd@0: % make list wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if nargin<2, enum = 0; end wolffd@0: cs = cell(0); wolffd@0: switch REPORT_OUTPUT_FMT wolffd@0: case {'ps','pdf'}, wolffd@0: if enum, tag = 'enumerate'; else tag = 'itemize'; end wolffd@0: starttag = ['\begin{' tag '}']; wolffd@0: listtag = '\item '; wolffd@0: endtag = ['\end{' tag '}']; wolffd@0: case 'html', wolffd@0: if enum, tag = 'OL'; else tag = 'UL'; end wolffd@0: starttag = ['<' tag '>']; wolffd@0: listtag = '

  • '; wolffd@0: endtag = ['']; wolffd@0: case 'txt', wolffd@0: starttag = ''; wolffd@0: listtag = '- '; wolffd@0: endtag = ''; wolffd@0: end wolffd@0: cs{end+1} = starttag; wolffd@0: for i=1:length(list), cs{end+1} = sprintf('%s %s',listtag,list{i}); end wolffd@0: cs{end+1} = endtag; wolffd@0: return; wolffd@0: wolffd@0: function csout = tablerow(cs,emp,span) wolffd@0: % construct one table row wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if nargin<2 | isempty(emp), emp = 'none'; end wolffd@0: if nargin<3 | isempty(span), span = ones(length(cs),2); end wolffd@0: rowspan = span(:,1); colspan = span(:,2); wolffd@0: switch emp, wolffd@0: case 'bold', emp1 = ''; emp2 = ''; wolffd@0: case 'italic', emp1 = ''; emp2 = ''; wolffd@0: case 'fixed', emp1 = ''; emp2 = ''; wolffd@0: case 'none', emp1 = ''; emp2 = ''; wolffd@0: case 'header', emp1 = ''; emp2 = ''; tag = 'TH'; wolffd@0: end wolffd@0: csout = cell(0); wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case {'pdf','ps'}, wolffd@0: %switch emp, wolffd@0: % case 'bold', emp1 = '{\bf '; emp2 = '}'; wolffd@0: % case 'italic', emp1 = '{\em '; emp2 = '}'; wolffd@0: % case 'fixed', emp1 = '{\tt '; emp2 = '}'; wolffd@0: % case 'none', emp1 = ''; emp2 = ''; wolffd@0: %end wolffd@0: s0 = ''; wolffd@0: for i=1:length(cs), wolffd@0: if rowspan(i) & colspan(i), wolffd@0: sp1 = ''; sp2 = ''; wolffd@0: if colspan(i)>1, sp1 = [sp1 ' \multicolumn{' num2str(colspan(i)) '}{|c|}{']; sp2 = [sp2 '}']; end wolffd@0: if rowspan(i)>1, sp1 = [sp1 ' \multirow{' num2str(rowspan(i)) '}{2cm}{']; sp2 = [sp2 '}']; end wolffd@0: s = s0; wolffd@0: content = cellstr(defaultformat(cs{i})); wolffd@0: csout{end+1} = [s sp1 emp1 content{1}]; wolffd@0: for j=2:length(content), csout{end+1} = content{j}; end wolffd@0: csout{end} = [csout{end} emp2 sp2]; wolffd@0: s0 = ' & '; wolffd@0: end wolffd@0: end wolffd@0: csout{end} = [csout{end} ' \\']; wolffd@0: case 'html', wolffd@0: tag = 'TD'; wolffd@0: csout{end+1} = ''; wolffd@0: for i=1:length(cs), wolffd@0: if rowspan(i) & colspan(i), wolffd@0: sp = ''; wolffd@0: if rowspan(i)>1, sp = [sp ' ROWSPAN=' num2str(rowspan(i))]; end wolffd@0: if colspan(i)>1, sp = [sp ' COLSPAN=' num2str(colspan(i))]; end wolffd@0: s = sprintf('<%s%s>%s',tag,sp,emp1); wolffd@0: content = cellstr(defaultformat(cs{i})); wolffd@0: csout{end+1} = [s content{1}]; wolffd@0: for j=2:length(content), csout{end+1} = content{j}; end wolffd@0: csout{end} = [csout{end} emp2 '']; wolffd@0: end wolffd@0: end wolffd@0: csout{end+1} = ''; wolffd@0: case 'txt', wolffd@0: for i=1:length(cs), csout{end+1} = defaultformat(cs{i}); end wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function cs = inserttable(sTable,rowlines,long) wolffd@0: % put table contents to cellstr wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if nargin<2, rowlines = 1; end wolffd@0: if nargin<3, long = 0; end wolffd@0: [rows cols] = size(sTable.values); wolffd@0: cs = cell(0); wolffd@0: if isempty(sTable.colfmt), cf = 'c'; sTable.colfmt = cf(ones(1,cols)); end wolffd@0: if isempty(sTable.span), sTable.span = ones([rows cols 2]); end wolffd@0: switch REPORT_OUTPUT_FMT wolffd@0: case {'ps','pdf','tex','latex'} wolffd@0: li1 = ' \hline'; wolffd@0: if rowlines>0, li2 = li1; li3 = li1; wolffd@0: elseif rowlines==0, li2 = ''; li3 = li1; wolffd@0: else li1 = ''; li2 = ''; li3 = ''; wolffd@0: end wolffd@0: if long, tbl = 'longtable'; else tbl = 'tabular'; end wolffd@0: cs{end+1} = ['\begin{' tbl '}{' sTable.colfmt '}' li1]; wolffd@0: if ~isempty(sTable.headers), wolffd@0: row = tablerow(sTable.headers,'bold'); wolffd@0: for i=1:length(row), cs{end+1} = row{i}; end wolffd@0: cs{end} = [cs{end} li1 li2]; wolffd@0: end wolffd@0: for i=1:rows, wolffd@0: row = tablerow(sTable.values(i,:),'',squeeze(sTable.span(i,:,:))); wolffd@0: for i=1:length(row), cs{end+1} = row{i}; end wolffd@0: cs{end} = [cs{end} li2]; wolffd@0: end wolffd@0: if ~rowlines, cs{end} = [cs{end} li3]; end wolffd@0: cs{end+1} = ['\end{' tbl '}']; wolffd@0: case 'html' wolffd@0: cs{end+1} = ['']; wolffd@0: if ~isempty(sTable.headers), wolffd@0: row = tablerow(sTable.headers,'header'); wolffd@0: for i=1:length(row), cs{end+1} = row{i}; end wolffd@0: end wolffd@0: for i=1:rows, wolffd@0: row = tablerow(sTable.values(i,:),'',squeeze(sTable.span(i,:,:))); wolffd@0: for i=1:length(row), cs{end+1} = row{i}; end wolffd@0: end wolffd@0: cs{end+1} = '
    '; wolffd@0: case 'txt' wolffd@0: cT = [sTable.headers(:)'; sTable.values]; wolffd@0: A = cell2char(cT); wolffd@0: for i=1:size(A,1), cs{end+1} = A(i,:); end wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function A = cell2char(T) wolffd@0: wolffd@0: [nrow,ncol] = size(T); wolffd@0: rowsep = 0; wolffd@0: colsep = 1; wolffd@0: wolffd@0: % change to strings wolffd@0: for i=1:nrow, wolffd@0: for j=1:ncol, wolffd@0: t = T{i,j}; wolffd@0: if ischar(t), % ok wolffd@0: elseif isempty(t), T{i,j} = ''; wolffd@0: elseif isstruct(t), % ?? wolffd@0: elseif iscell(t), T{i,j} = cell2char(t); wolffd@0: elseif isnumeric(t), T{i,j} = num2str(t,3); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: % widths of columns and heights of rows wolffd@0: HW = ones(nrow,ncol,2); wolffd@0: for i=1:nrow, for j=1:ncol, HW(i,j,:) = size(T{i,j}); end, end wolffd@0: colw = max(HW(:,:,2),[],1); wolffd@0: rowh = max(HW(:,:,1),[],2); wolffd@0: wolffd@0: % the table itself wolffd@0: A = char(32*ones(sum(rowh)+rowsep*(nrow-1),sum(colw)+colsep*(ncol-1))); wolffd@0: for i=1:nrow, wolffd@0: for j=1:ncol, wolffd@0: i0 = (i-1)*rowsep+sum(rowh(1:i-1)); wolffd@0: j0 = (j-1)*colsep+sum(colw(1:j-1)); wolffd@0: S = char(32*ones(rowh(i),colw(j))); wolffd@0: si = size(T{i,j}); S(1:si(1),1:si(2)) = T{i,j}; wolffd@0: A(i0+[1:rowh(i)],j0+[1:colw(j)]) = S; wolffd@0: end wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: wolffd@0: function s = inserttominipage(s,width) wolffd@0: if nargin<2 | isempty(width) | isnan(width), width = 1; end wolffd@0: width = ['{' num2str(width) '\columnwidth}']; wolffd@0: mp1 = '\begin{minipage}[t]'; mp2 = '\end{minipage}'; wolffd@0: if size(s,1)==1, s = [mp1 width s mp2]; wolffd@0: else s = char({[mp1 width]; s; mp2}); wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function cs = insertfigure(fname,boxsize,inminipage) wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if nargin<2, boxsize = [NaN 1]; end wolffd@0: if nargin<3, inminipage = 0; end wolffd@0: htmlpagewidth = 800; wolffd@0: si = cell(0); wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case {'ps','pdf'}, wolffd@0: if ~isnan(boxsize(1)), si{end+1} = ['height=' num2str(boxsize(1)) '\textheight']; end wolffd@0: if ~isnan(boxsize(2)), si{end+1} = ['width=' num2str(boxsize(2)) '\columnwidth']; end wolffd@0: if length(si), si = [', ' joinstr(si, ', ', ', ')]; end wolffd@0: case 'html', wolffd@0: if ~isnan(boxsize(1)), si{end+1} = ['HEIGHT=' num2str(htmlpagewidth*boxsize(1))]; end wolffd@0: if ~isnan(boxsize(2)), si{end+1} = ['WIDTH=' num2str(htmlpagewidth*boxsize(2))]; end wolffd@0: if length(si), si = [' ' joinstr(si, ' ', ' ')]; end wolffd@0: case 'txt', wolffd@0: % nil wolffd@0: end wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case 'ps', s = ['\epsfig{file=./' fname '.ps ' si '}']; wolffd@0: case 'pdf', s = ['\includegraphics[' si ']{./' fname '.pdf}']; wolffd@0: case 'html', wolffd@0: fn = [fname '.' fmt2imgfmt]; wolffd@0: s = ['' fname '']; wolffd@0: s = makelinkfrom(fn,s); wolffd@0: case 'txt', wolffd@0: s = ['[image:' fname ']']; wolffd@0: end wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case {'ps','pdf'}, wolffd@0: if inminipage, s = inserttominipage(s,boxsize(2)); end wolffd@0: case 'html', wolffd@0: s = ['
    ' s '
    ']; wolffd@0: case 'txt', wolffd@0: % nil wolffd@0: end wolffd@0: cs = {s}; wolffd@0: return; wolffd@0: wolffd@0: function str = makelinkfrom(linkto,anchor) wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: if iscell(linkto), wolffd@0: if strcmp(REPORT_OUTPUT_FMT,'html'), linkto = joinstr(linkto,'','#'); wolffd@0: else linkto = joinstr(linkto,'',''); wolffd@0: end wolffd@0: end wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case 'pdf', str = ['\hyperlink{' linkto '}{' anchor '}']; wolffd@0: case 'ps', str = [anchor ' (p.\pageref{' linkto '})']; wolffd@0: case 'html', str = ['' anchor '']; wolffd@0: case 'txt', str = ''; wolffd@0: end wolffd@0: return; wolffd@0: wolffd@0: function str = makelinkto(linkname) wolffd@0: global REPORT_OUTPUT_FMT wolffd@0: switch REPORT_OUTPUT_FMT, wolffd@0: case 'pdf', wolffd@0: fmt = '\pdfdest name {%s} fit \pdfoutline goto name {%s} {%s}'; wolffd@0: str = sprintf(fmt,linkname,linkname,linkname); wolffd@0: case 'ps', str = ['\label{' linkname '}']; wolffd@0: case 'html', str = [' ']; wolffd@0: case 'txt', str = ''; wolffd@0: end wolffd@0: return; wolffd@0: