I am writing a article include both mathematics and English. See my code below:

\usepackage[sc,osf]{mathpazo}   % With old-style figures and real smallcaps.
\linespread{1.025}              % Palatino leads a little more leading

\usepackage[margin=0.8cm]{geometry}% http://ctan.org/pkg/geometry

% Euler for math and numbers


\newcommand{\problemtitle}[1]{\gdef\@problemtitle{#1}}% Store problem title
\newcommand{\probleminput}[1]{\gdef\@probleminput{#1}}% Store problem input
\newcommand{\problemquestion}[1]{\gdef\@problemquestion{#1}}% Store problem question
  \problemtitle{}\probleminput{}\problemquestion{}% Default input is empty
  \BODY% Parse input
  \begin{tabularx}{\textwidth}{@{\hspace{\parindent}} l X c}
    \multicolumn{2}{@{\hspace{\parindent}}l}{\@problemtitle} \\% Title
    \textbf{Input:} & \@probleminput \\% Input
    \textbf{Question:} & \@problemquestion% Question


% No easy way of putting the theorem description in italics?
% It seems I need to define a new style...
   {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}% 
   {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ \textit{(##3)}\theorem@separator]}



\title{Computing Prime Set In  $\mathcal{O}(k)$ Time}
\author{She ssrma\\~\\ shi.arma@iitgn.in \\~\\ IIdd Gandagar}

\date {Jan-2018}


\textbf{Prime Set} \\
\textbf{Input : } An array $N$ such that $N[i] = i, 2\le i \le k-1$.\\
\textbf{Find : } $Q_{k-1} = \{p \in [k-1] \mid p \text { \hspace*{0.001cm} is \hspace*{0.001cm} prime}\}$ \\

compiled doc is :

enter image description here

Question : How to correct misalignment (prime set is misaligned ) and there is a spacing problem where I have written $p$ is prime?

  • 1
    Putting \noindent before \textbf{Prime Set} will do the job.
    – user121799
    Feb 13 '18 at 13:43
  • 3
    Which spacing problem?
    – Bernard
    Feb 13 '18 at 13:44
  • see the in the last line of compiled pdf . I have written English inside { } p I s prime
    – new_born
    Feb 13 '18 at 13:45
  • But you adjusted the spacing by hand. What do you expect?
    – user121799
    Feb 13 '18 at 14:03
  • 1
    That's an accident, because you are inserting spacing both before and after \hspace. I guess you want just \mid p \text { is prime} (note the first space in the argument of \text) or maybe \mid \text{$p$ is prime}.
    – campa
    Feb 13 '18 at 14:19

I think you should set up a dedicated, two-column tabular environment. In the example below, the first column is of type l, and the second is of type p to allow for line wrapping, if needed.

Observe also that I recommend replacing

p \text { \hspace*{0.001cm} is \hspace*{0.001cm} prime}


\text{$p$ is prime}

Somewhat simpler, isn't it?

enter image description here

%% I've simplified the preamble to the bare essentials
\usepackage{amsmath} % for "\text" macro

\usepackage{newpxtext,newpxmath} % 'mathpazo' is obsolete
\linespread{1.025} %Palatino needs a little more leading


\multicolumn{2}{@{}l}{\textbf{Prime Set}}\\
\textbf{Input} & An array $N$ such that $N[i] = i$, $2\le i \le k-1$\\
\textbf{Find}  & $Q_{k-1} = \{\, p \in [k-1] \mid \text{$p$ is prime} \,\}$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.