9

I’m am trying to create a pdf file from matlab figure using cmyk colors, but facing a problem with umlauts and also some other special characters. Is there any other way to handle this than Latex? The following example demonstrates the issue.

plot(rand(199,1))
title_string = ['Some text:äö' char(228) ':2005' char(150) '2008:end text'];
title(title_string);
print(gcf,'-dpdf','cmykfile.pdf','-r600','-cmyk'); 
print(gcf,'-dpdf','rgbfile.pdf','-r600');

As you can see from the pdf-files the RGB-version handles umlauts, but not en-dash, and CMYK skips them all.

PDF is generated in Matlab using Ghostscript, but I have not found how to configure character encoding for GS.

I am using Windows and Matlab R2014.

Pekka
  • 91
  • 2
  • 2
    This is a part of a larger problem of printing `unicode` characters in MATLAB. See these posts on the topic: [q1](http://stackoverflow.com/questions/7014476/is-it-possible-to-print-unicode-text-or-characters-in-matlab), [a1](http://stackoverflow.com/a/6872642/3372061) – Dev-iL Aug 21 '14 at 07:43
  • besides the links in the comment above, you can check out project waterloo: http://waterloo.sourceforge.net/index.html – bla Aug 21 '14 at 07:50
  • Thank you for the comments. I have read pages of posts on this and other forums, but these ones were new to me. The first one seems most interesting and javacomponent already gave promising results. – Pekka Aug 21 '14 at 08:55
  • Text in javaobjects does not print as vector graphics... – Pekka Aug 21 '14 at 10:31
  • I'd really go for latex. With matlab2tikz and good settings in pgfplots a plot is not just ok, but really publication quality. The matlab export features are the worst features I ever found. – mike Sep 05 '14 at 12:55
  • 3
    Why do you want to avoid latex? Perhaps the reason for that is easier to solve instead. – Dennis Jaheruddin Sep 09 '14 at 13:23
  • 2
    I have not been able to change the font in latex (to Arial type font). So far the best solution is to print RGB pdf and convert that to CMYK using Acrobat Pro. – Pekka Sep 26 '14 at 21:11
  • Changing the font may actually be possible, but it is definitely not trivial: http://nl.mathworks.com/matlabcentral/newsreader/view_thread/114116 – Dennis Jaheruddin Nov 27 '14 at 15:51
  • Unicode appears to be (better?) supported in R2015a – A. Donda May 07 '15 at 16:37

1 Answers1

1

I'm not completely sure this is the solution you was looking for. Anyway, if you create an eps first and then convert it to pdf the output file doesn't have any issue with the special characters in the title, provided that you don't build your title string using char.

plot(rand(199,1))
title_string = 'Some text:äöä:2005—2008æ:end text';
title(title_string);
print(gcf,'-depsc','cmykfile.eps','-r600','-cmyk'); 
!ps2pdf cmykfile.eps cmykfile.pdf

The code above works if you have the ps2pdf utility in your system path. You already have ps2pdf on your computer if you have MiKTeX installed, but you might need to update your system path. Basically ps2pdf should be a shortcut to gs, therefore also if you have only gs and not MiKTeX installed, you should be able to achieve the same result.


EDIT

On my machine (Windows 7, MATLAB R2014b), also this code works well, without the need to use ps2pdf:

plot(rand(199,1))
title_string = 'Some text:äöä:2005—2008æ:end text';
title(title_string);
print(gcf,'-dpdf','cmykfile.pdf','-r600','-cmyk');

It seems that the issue happens when you build the title string using char.

lmillefiori
  • 486
  • 3
  • 9