You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My matlab2tikz workflow heavily involves sneaking in Tex macros into matlab2tikz arguments such as 'width', 'height', 'extraAxisOptions', 'relativeDataPath' to control the figure appearance from within my Latex document.
However, I am facing a problem with relativeDataPath. I would like to set this option to \figuredatadir, which is a macro set by my Latex main document. This works well under Linux, but is a problem now as I am switching to Windows. The problem is that under Windows, the backslash \ will be replaced by a forward slash /.
The responsible line is in the internal function TeXpath:
Currently, I am helping me out with a quite dirty hack by having a function strrep in my workspace which overrides MATLAB's builtin strrep function to avoid patching my copy of matlab2tikz:
% THIS IS A HACK FOR MATLAB2TIKZ
%
% When setting 'relativeDataPath' as a matlab2tikz option, the following
% function comes into play:
%
% function path = TeXpath(path)
% path = strrep(path, filesep, '/');
% % TeX uses '/' as a file separator (as UNIX). Windows, however, uses
% % '\' which is not supported by TeX as a file separator
% end
%
% This function prevents to have the Tex command '\figuredatadir' replaced in
% 'relativeDataPath' when runnning under Windows. For Linux or Mac OS, this
% hack is not necessary.
function varargout = strrep(varargin)
[varargout{1:nargout}] = builtin('strrep',varargin{:});
% Different behavior if caller function is "TeXpath" in file "matlab2tikz.m"
curStack = dbstack();
if length(curStack)>1 && strcmp(curStack(2).file,'matlab2tikz.m') && strcmp(curStack(2).name,'TeXpath')
varargout{1} = strrep(varargout{1},'/figuredatadir','\figuredatadir');
end
end
I am not even sure if the mentioned behavior can be called a bug. If not, I would like to know if there is any better or even recommended way to sneak in Latex commands into relativeDataPath? You may also put this a feature request.
Thank you.
The text was updated successfully, but these errors were encountered:
My matlab2tikz workflow heavily involves sneaking in Tex macros into matlab2tikz arguments such as 'width', 'height', 'extraAxisOptions', 'relativeDataPath' to control the figure appearance from within my Latex document.
However, I am facing a problem with
relativeDataPath
. I would like to set this option to\figuredatadir
, which is a macro set by my Latex main document. This works well under Linux, but is a problem now as I am switching to Windows. The problem is that under Windows, the backslash\
will be replaced by a forward slash/
.The responsible line is in the internal function
TeXpath
:matlab2tikz/src/matlab2tikz.m
Line 462 in cf27b2d
Currently, I am helping me out with a quite dirty hack by having a function
strrep
in my workspace which overrides MATLAB's builtinstrrep
function to avoid patching my copy of matlab2tikz:I am not even sure if the mentioned behavior can be called a bug. If not, I would like to know if there is any better or even recommended way to sneak in Latex commands into
relativeDataPath
? You may also put this a feature request.Thank you.
The text was updated successfully, but these errors were encountered: