xelatex stop running with no error raised - centos

I run my tex file on CentOS7 using xelatex. I can see its progress in top but seems it stopped runnning with no error raised. And the final sentence on screen is:
(/project/RD/transcriptome/software/texlive/2020/texmf-dist/tex/latex/lm/omxlmex.fd)
Then it stopped here, no more running record on screen.
And if I press Ctrl+C to stop, it shows like this:
! Interruption.
__kernel_file_name_expand_loop:w ..._group:nTF {#1
}{__kernel_file_name_expan...
l.78 \end{titlepage}
?
tex scripts near line 78 is like this:
\begin{document}
% 封面设置
\begin{titlepage}
% 封面图
\ThisCenterWallPaper{1.2}{titlepages.png}
\heiti
\begin{center}
\vspace*{90pt}
\zihao{2} \textbf{Company Name}\\
\vspace*{20pt}
\zihao{2} \textbf{Report Name}\\
\vspace*{200pt}
\end{center}
\begin{table}[h!]
\centering
\begin{tabular}{lcc}
\zihao{-3} Series Number:& 00000000 \\
\specialrule{0em}{5pt}{5pt}
\zihao{-3} Project Type:& 转录组 \\
\specialrule{0em}{5pt}{5pt}
\zihao{-3} Customer Name:& XXX \\
\specialrule{0em}{5pt}{5pt}
\zihao{-3} Customer Company:& XXXX \\
\specialrule{0em}{5pt}{5pt}
\zihao{-3} Sample Number:& 40 \\
\specialrule{0em}{5pt}{5pt}
\zihao{-3} Report Date:& \today \\
\end{tabular}
\end{table}
\end{titlepage} % Here is line 78.
And I don't know why it stopped but no error raised, and did it really stop? I can still see its progress in top and its status is 'R'.
if any error is found, please tell me! Thanks!! :)
I have updated a sample here.
%!TEX program = xelatex
\documentclass[UTF8]{article}
\usepackage{ctex} % 编译中文
\usepackage[a4paper]{geometry} % 这个包用来调整纸张大小和页边距
\geometry{left=2.0cm,top=2.0cm,right=2.0cm,bottom=2.0cm}
\usepackage{setspace} % 设置行距
\setlength{\parindent}{2em} % 设置首行缩进
% 字体相关
\usepackage{fontspec} % 用于设置英文字体
\setmainfont{Times New Roman}
\setsansfont{Arial}
\usepackage{xeCJK} % 用于设置中文字体
\setCJKmainfont{SimSun-Regular}
\setCJKsansfont{Heiti-Light}
% 图表相关
\usepackage{graphicx} % 插入图片
\usepackage{caption} % 插入图片标题
\usepackage{wallpaper} % 添加背景图
\usepackage{amsmath}
\usepackage{colortbl}
% 页眉页脚
\usepackage{fancyhdr}
\pagestyle{fancy}
% \fancyhead{} % 初始化页眉
\rhead{\bfseries Right head od this page}
\lhead{\includegraphics[scale=0.35]{anyPicture.png}} % Any picture here, just for test.
% \fancyfoot{} % 初始化页脚
\cfoot{page foot text here}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
\begin{document}
% 封面设置
\begin{titlepage}
% 封面图
\ThisCenterWallPaper{1.2}{anyCoverPic.png} % You can put any picture here as a cover.
\begin{center}
\vspace*{90pt}
\zihao{2} \textbf{Title}\\
\vspace*{20pt}
\zihao{2} \textbf{subtitle}\\
\vspace*{200pt}
\end{center}
\end{titlepage}
\section{Part1 -A sample}
\begin{spacing}{1.5}
Here is the test text.Just for test.
\end{spacing}
\end{document}

Related

\hline issue with LaTex when importing table from different .tex file into a tabular environment

I'm having an issue where at certain points using the \hline function creates an error and instead displays the word "height" where there should be a line. This is happening only when I use an /hline immediately after using a \input{".../filename.tex"} command in a tabular environment. Interestingly, though, adding an \hline to the last row of the file I am importing produces an \hline properly. Does anyone have an idea why this may be the case and what I can do to fix it so that I can add the \hline to the main file and not the files I'm importing. Note that I use TexMaker and MiKTeX
Here are some examples of my code that doesn't work:
\documentclass{12pt, english}{article}
\usepackage{geometry}
\usepackage{caption}
\usepackage{tocvsec2}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{subfloat}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{tabu}
\usepackage{titlesec}
\usepackage{tocloft}
\begin{document}
\begin{table}
\caption{Caption} \label{tab:label} \centering
\begin{tabular}{lccc}
\hline
\import{".../filename.tex"}
\hline
\end{tabular}
\begin{minipage}{0.95}
Notes are here
\end{minipage}
\end{table}
\end{document}
where filename.tex looks like this (with nothing else):
& Mean & SD & N \\
\midrule
Var 1 & 1 & 0 & 1000 \\
Var 2 & 1 & 0 & 1000 \\
Var 3 & 1 & 0 & 1000 \\
Var 4 & 1 & 0 & 1000 \\
Var 5 & 1 & 0 & 1000 \\
When I move the last \hline to the end of filname.tex, however, it works fine.
You can use the same trick as in https://tex.stackexchange.com/a/50700/36296
Other problems:
the syntax \documentclass{12pt, english}{article} is wrong
the booktabs package is missing
missing unit in \begin{minipage}{0.95}
you really, really, really shouldn't use the tabu package, it is more or less completely broken
don't load the same package multiple times
\documentclass[12pt, english]{article}
\usepackage{geometry}
\usepackage{caption}
\usepackage{tocvsec2}
\usepackage{graphicx}
\usepackage{multirow}
%\usepackage{tabularx}
\usepackage{subfloat}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{tabulary}
%\usepackage{tabu}
\usepackage{titlesec}
\usepackage{tocloft}
\usepackage{booktabs}
\begin{filecontents*}[overwrite]{test.tex}
& Mean & SD & N \\
\midrule
Var 1 & 1 & 0 & 1000 \\
Var 2 & 1 & 0 & 1000 \\
Var 3 & 1 & 0 & 1000 \\
Var 4 & 1 & 0 & 1000 \\
Var 5 & 1 & 0 & 1000 \\
\end{filecontents*}
\makeatletter
\newcommand\primitiveinput[1]
{\##input #1 }
\makeatother
\begin{document}
\begin{table}
\caption{Caption} \label{tab:label} \centering
\begin{tabular}{lccc}
\hline
\primitiveinput{test}
\hline
\end{tabular}
\begin{minipage}{0.95cm}
Notes are here
\end{minipage}
\end{table}
\end{document}

Ghostscript ps2pdf not Working Correctly from MATLAB

I have a .tex file I am attempting to write from a MATLAB environment (2017b) using first latex, then dvips, and finally ps2pdf to create the PDF file. The PDF file is properly created when I run it through TeXWorks, but sends an error from ps2pdf when I try to run it through. I'm not entirely sure what's wrong with the way I send it to the command line. Here is the script I am attempting to run.
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');
set(0,'defaultTextInterpreter','latex');
addpath('C:\Program Files (x86)\MiKTeX\miktex\bin\x64')
exampledir='\\our\server\';
examplefilename='test';
texdoc=fullfile(exampledir,strcat(examplefilename,'.tex'));
auxdoc=fullfile(exampledir,strcat(examplefilename,'.aux'));
logdoc=fullfile(exampledir,strcat(examplefilename,'.log'));
dvidoc=fullfile(exampledir,strcat(examplefilename,'.dvi'));
psdoc=fullfile(exampledir,strcat(examplefilename,'.ps'));
pdfdoc=fullfile(exampledir,strcat(examplefilename,'.pdf'));
fileID = fopen(texdoc,'w');
textext=['\documentclass[twoside]{article} %Two-sided document. Required for fancyhf left and right page numbering scheme current.' newline ...
'\usepackage{graphicx}' newline ...
newline ...
'\usepackage{fancyhdr} %Use the package fancy header/footer' newline ...
newline ...
'\usepackage[letterpaper,margin=0.5in,bottom=0.75in,top=0.7in]{geometry} %Ensure the paper is letterpaper.' newline ...
'\usepackage{grffile}' newline ...
'\usepackage{caption}' newline ...
'\usepackage{float} %Float used to position graphics.' newline ...
'\usepackage{lastpage209} %For last page' newline ...
newline ...
'\DeclareGraphicsExtensions{.PDF,.jpg} %Notify LaTeX what type of graphics extensions to expect.' newline ...
newline ...
'\renewcommand{\headrulewidth}{0pt} % remove the header rule' newline ...
newline ...
'\fancyhf{} % clear all header and footers' newline ...
newline ...
'\pagestyle{fancy} %Use the fancy pagestyle, which will include the fancy header and footer options we defined above.' newline ...
newline ...
'\setlength\headheight{38pt} ' newline ...
newline ...
'\fancyhead[L]{{Page \thepage} of \pageref{LastPage}} %Left side on even pages; right side on odd pages.' newline ...
'\fancyhead[R]{\includegraphics[trim={0.3in 0.26in 0.05in 0.26in},clip,width=0.4in]{{\\our\server\mypicture}}}' newline ...
newline ...
'\begin{document} %This will be the actual document and what goes into it.' newline ...
newline ...
'\begin{figure}[h] %Make a figure...' newline ...
newline ...
' \includegraphics[trim={0.25in 0 0 0},clip,width=7.5in]{{\\our\server\mypicture}}' newline ...
newline ...
' \captionsetup{labelformat=empty}' newline ...
newline ...
'\end{figure}' newline ...
newline ...
'\end{document}'];
fprintf(fileID,'%s',textext);
fclose(fileID);
% latex dvips ps2pdf
% text.tex -------> text.dvi -------> text.ps --------> text.pdf
[~,cmdoutlatex] = system(['latex.exe -interaction=nonstopmode -output-directory ' exampledir '\ ' texdoc]);
if contains(cmdoutlatex,'Sorry, but latex.exe did not succeed.')
%Do some kind of check and fix things.
end
[~,cmdoutdvips] = system(['dvips.exe -q* -o ' psdoc ' ' dvidoc]);
if contains(cmdoutdvips,'!')
%Do some kind of check and fix things.
error(['Error: ' cmdoutdvips])
end
[~,cmdoutps2pdf] = system(['ps2pdf ' psdoc ' ' pdfdoc ' -sDEVICE=pdfwrite']);
if contains(cmdoutps2pdf,'Error','IgnoreCase',true)
%Do some kind of check and fix things.
error(cmdoutps2pdf)
end
Per #Cris Luengo's suggestion of moving to pdflatex rather than using latex/dvips/ps2pdf commands, this worked. Here is the sample code of what worked for a system command.
[~,pdflatexout] = system(['pdflatex.exe -output-directory ' strrep(exampledir,'\','/') ' ' texdoc]);
%Check for errors.
if contains(pdflatexout,'Sorry, but pdflatex.exe did not succeed.') || ...
contains(pdflatexout,'error','IgnoreCase',true)
%Deliver the error code.
error(pdflatexout)
end
I placed this after fclose(fileID) in the original code and deleted all that had originally come after that line.

Syntax error when running matlab code

I downloaded some matlab code, when trying to run a test file, it ends finding a syntax error, this one here:
parse error near line 151 of file /media/34GB/escola/efficientLBP/pixelwiseLBP.m
syntax error
>>>> [minLBP, ~]=sortNeighbours( binaryWord, weigthVec,...
^
The code it is:
else % if iChan==1 || isChanWiseRot
[minLBP, ~]=sortNeighbours( binaryWord, weigthVec,...
iCircShiftMinLBP(iRow, iCol) );
What is wrong here? Thanks for the time.
P.S: EDITED
Here is the extra code requested:
for iRow=( filtDimsR(1)+1 ):( padImgSize(1)-filtDimsR(1) )
for iCol=( filtDimsR(2)+1 ):( padImgSize(2)-filtDimsR(2) )
subImg=chanImgPad(iRow+( -filtDimsR(1):filtDimsR(1) ),...
iCol+( -filtDimsR(2):filtDimsR(2) ));
% find differences between current pixel, and it's neighours
diffVec=sum(sum( filtR.*repmat(subImg,[1, 1, nNeigh]) ));
diffVec=roundnS(diffVec, nEps);
binaryWord=( diffVec(:)>=0 );
if isRotInv
if iChan==1 || isChanWiseRot % go through all posible binary
% word combination, finding minimal LBP
[minLBP, iCircShiftMinLBP(iRow, iCol)]=...
sortNeighbours(binaryWord, weigthVec);
else % if iChan==1 || isChanWiseRot
[minLBP, ~]=sortNeighbours( binaryWord, weigthVec,...
iCircShiftMinLBP(iRow, iCol) );
end % if iChan==1 || isChanWiseRot
else
minLBP=weigthVec*binaryWord;
end % if isRotInv
currChanLBP(iRow, iCol)=cast( minLBP, outClass); % convert to decimal.
end % for iCol=(1+filtDimsR(2)):(imgSize(2)-filtDimsR(2))
% Present waitbar- a bar with progress, time passed and time remaining
waitbarTimeRemaining(hWaitbar, hTicPixelwiseLBP,...
(( iRow-filtDimsR(1) )+nRows*(iChan-1))/(nClrChans*nRows));
end % for iRow=(1+filtDimsR(1)):(imgSize(1)-filtDimsR(1))

matlab - Error using ./ Matrix dimensions must agree

Why am i getting this error?
In this program I want to get a linear regression. Next, I want to remove outlier data. Then, outliers are colored red, and normal points colored blue, the fitting line is colored green.
In this program in end command occurs an error. Can someone help me understand why?
x=[-0.05623 -0.20968 0.192102 0.992332 0.576244 1.305784 ...
-0.72931 -0.86457 -0.09492 1.383214 1.303681 -0.12581 ...
-0.59687 -1.52065 0.671842 0.022844 -1.17779 -0.33458 ...
-1.82946 0.42999 -0.17399 1.631242 -1.35943 0.970507 ...
0.14364 0.082604 0.716664 1.193484 -1.07106 1.318902 ...
-1.21 -1.07411 -0.67256 0.736462 -1.06996 0.334715 ...
0.411883 0.15412 0.554571 -1.17285 1.007587 0.11352 ...
0.730051 -0.98351 0.052032 0.877599 1.014141 -0.08435 ...
-1.85353 -1.09682 0.218628 0.794246 0.463124 -0.61263 ...
2.2444 0.072348 0.865514 -0.4157 -1.11494 0.685252 ...
1.037673 1.822212 -0.52899 -1.62797 1.617302 0.264137 ...
-1.12715 -0.55918 -0.80885 1.161004 0.592105 0.242748 ...
0.240477 -0.8215 0.993112 0.346395 -0.26113 -0.18471 ...
-0.10173 -0.88704 0.741377 1.392208 2.4739 0.503919 ...
-0.82248 0.200982 -1.00705 -0.61317 -0.65896 -0.83323 ...
0.378179 -1.11534 0.667241 0.795333 1.037492 -0.02043 ...
0.618953 1.803064 0.052993 -0.17789];
y=[5.436978 3.947596 5.153861 7.203315 5.725703 6.793873 3.545316 3.936359 ...
4.237048 6.839705 7.122279 4.810857 4.288197 2.756219 6.208018 4.655615 ...
3.29746 4.037378 2.486194 5.55364 4.931752 7.288785 3.057518 6.765781 ...
4.633195 4.574674 5.536068 7.039812 3.51258 6.771749 3.625891 3.429356 ...
3.524448 5.804945 2.987637 5.782922 5.441024 4.886507 5.662118 2.994722 ...
6.762253 5.310672 6.183994 3.647019 5.090687 6.037325 6.680508 4.631969 ...
1.904436 3.03886 5.583692 6.479913 5.177385 4.037497 8.4407 4.928997 ...
6.522089 4.451288 3.282642 5.863934 6.755633 7.983111 4.344549 2.487526 ...
7.696832 5.129475 3.351763 4.571945 3.730939 6.493319 6.459757 5.291498 ...
5.490604 3.531393 6.574259 5.65695 4.609641 4.81884 5.201688 3.25646 ...
6.172526 6.502666 8.719206 6.323678 4.043084 5.299436 3.389938 4.235615 ...
4.322408 3.754491 6.042199 3.087029 5.413286 5.972943 6.497619 4.859718 ...
5.679203 8.097901 4.604103 4.588513];
n=1
p=polyfit(x,y,n);
a=p(1); b=p(2);
ymodel=a*x+b;
plot(x,y,'o',x,ymodel);
all_idx = 1:length(x);
outlier_idx = abs(x -median(x)) > 2*std(x) | abs(y - median(y)) > 2*std(y)
x(outlier_idx) = interp1(all_idx(~outlier_idx), ...
x(~outlier_idx), all_idx(outlier_idx));
y(outlier_idx) =interp1(all_idx(~outlier_idx), ...
y(~outlier_idx), all_idx(outlier_idx));
x_out_ind = find(outlier_idx); % gives the index of outliers
% the next line gives an error: matrix dimensions must agree:
x_normal_ind = find(ones(1,00)-x_out_ind); % gives the index of normal
for i=x_normal_ind
% this plot command gives an error:
plot(x(i),y(i),'o','blue')
hold on
end
for i=x_out_ind
% this plot command gives an error:
plot(x(i),y(i),'o','red')
hold on
end
plot(x,a*x+b,'green')
First error is because ones(1,00) will return an empty matrix which is not the same size as x_out_ind i.e. matrix dimensions do not agree.
Second error is because you have supplied two strings to the plot command. This is often treated as a 'property':'value' pairing. So it is saying that the property 'o' is not valid.
I'd suggest using 'dbstop if error' and track down the errors one at a time.

Ghostscript error converting multi-page PS to multi-page PDF using pdfwrite

I'm using Matlab to output a multi-page PS file:
print(figure, '-dpsc2', fullfile(folder, [file '.ps']), '-r600', '-append')
and then using Matlab to invoke Ghostscript to convert the resulting PS file to a PDF:
system(['"' gsPath '" -sDEVICE=pdfwrite \
-dDEVICEWIDTHPOINTS=' num2str(int32(width*72)) ' \
-dDEVICEHEIGHTPOINTS=' num2str(int32(height*72)) ' \
-dPDFFitPage \
-o "' fullfile(folder, [file '.pdf']) '" "' fullfile(folder, [file '.ps']) '"']);
which is just a really hard-to-read way of writing something along the lines of
gswin64c -sDEVICE=pdfwrite ^
-dDEVICEWIDTHPOINTS=100 ^
-dDEVICEHEIGHTPOINTS=100 ^
-dPDFFitPage ^
-o "C:\folder\output.pdf" "C:\folder\input.ps"
where I've put in example values for device dimensions and input/output paths. When I use this code to print a single figure (one page) to PDF, everything works perfectly. However, when printing multiple figures (multiple pages) to PDF, Ghostscript throws an error:
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
**** Unable to open the initial device, quitting.
Now, if I remove the -dDEVICEWIDTHPOINTS=100 -dDEVICEHEIGHTPOINTS=100 part of my Ghostscript command and again attempt to print multiple figures to a PDF, it works fine (except for the page size being different than what I want).
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanL-Regu... 4032872 2490784 2311720 1014184 2 done.
Has anyone else run into a similar problem and found a workaround for this issue? One of the keys here is that I need to be able to control the page size of the PDF produced. Thanks!
Below is an example that should run fine. First we create a multi-page PS file:
fname = 'test';
if exist([fname '.ps'], 'file'), delete([fname '.ps']); end
hfig = figure;
for i=1:10
plot(cumsum(rand(100,1)-0.5))
drawnow
print(hfig, '-dpsc2', '-append', [fname '.ps'])
end
close(hfig)
Next we convert it to PDF using Ghostscript, and properly crop the figures:
gs_path = 'C:\Program Files\gs\gs9.07\bin\gswin64c.exe';
gs_opts = '-dBATCH -dNOPAUSE -q';
% ps2pdf
cmd = sprintf('"%s" %s -sDEVICE=pdfwrite -dPDFFitPage -o %s %s', ...
gs_path, gs_opts, [fname '.pdf'], [fname '.ps']);
disp(cmd); system(cmd);
% get bbox
cmd = sprintf('"%s" %s -sDEVICE=bbox %s', ...
gs_path, gs_opts, [fname '.pdf']);
disp(cmd); [~,out] = system(cmd);
out = textscan(out, '%s', 'Delimiter','');
bbox = regexp(out{1}, '^%%BoundingBox: (\d+) (\d+) (\d+) (\d+)','tokens','once');
bbox = str2double(vertcat(bbox{:}));
bbox = [min(bbox(:,1:2)) max(bbox(:,3:4))];
% crop to bounding box
cmd = sprintf(['"%s" %s -o %s -sDEVICE=pdfwrite' ...
' -dDEVICEWIDTHPOINTS=%d -dDEVICEHEIGHTPOINTS=%d -dFIXEDMEDIA' ...
' -c "<</PageOffset [-%d -%d]>> setpagedevice" -f %s'], ...
gs_path, gs_opts, [fname '_cropped.pdf'], ...
bbox(3)-bbox(1), bbox(4)-bbox(2), bbox(1), bbox(2), [fname '.pdf']);
disp(cmd); system(cmd);