3

How can I set part name and title on the same line. Now (at default) , the Part number is at one line, and the name of part is one line below... For example, instead of

PART I
This is my title

I want

PART I   This is my title

Here is a simple code:

% Preview source code

%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\begin{document}

\part{why this line is one line down?}

How can I make the the name of part one will be at the same line at
the PDF output.
\end{document}

Edit: Here is my document preamble:

% Preview source code

%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,hebrew]{article}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[cp1255]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=3cm}
\setlength{\parindent}{0bp}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[all]{xy}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}
\newenvironment{proof}%
{\R{\textbf{הוכחה:}}}%
{\hfill\rule{2mm}{2mm}\par\vspace{2mm}}
\newtheorem{claim}[theorem]{\R{טענה}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{cancel}
\usepackage{pifont}
\usepackage{keystroke}
\usepackage{bbding}
\makeatletter
\newcommand{\xyR}[1]{%
\makeatletter
\xydef@\xymatrixrowsep@{#1}
\makeatother
} % end of \xyR
\makeatletter
\newcommand{\xyC}[1]{%
\makeatletter
\xydef@\xymatrixcolsep@{#1}
\makeatother
} % end of \xyC
\def\thepart{\alph{part}}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\@part}{\par}{\quad}{}{}
\patchcmd{\@part}{\Large}{\huge}{}{}
\makeatother

\makeatother

\usepackage{babel}
\begin{document}

When I adding the code above to this, it's doesn't work...


Here is my document preamble:

% Preview source code

%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,hebrew]{article}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[cp1255]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=3cm}
\setlength{\parindent}{0bp}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[all]{xy}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}
\newenvironment{proof}%
{\R{\textbf{הוכחה:}}}%
{\hfill\rule{2mm}{2mm}\par\vspace{2mm}}
\newtheorem{claim}[theorem]{\R{טענה}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{cancel}
\usepackage{pifont}
\usepackage{keystroke}
\usepackage{bbding}
\makeatletter
\newcommand{\xyR}[1]{%
\makeatletter
\xydef@\xymatrixrowsep@{#1}
\makeatother
} % end of \xyR
\makeatletter
\newcommand{\xyC}[1]{%
\makeatletter
\xydef@\xymatrixcolsep@{#1}
\makeatother
} % end of \xyC
\def\thepart{\alph{part}}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\@part}{\par}{\quad}{}{}
\patchcmd{\@part}{\Large}{\huge}{}{}
\makeatother

\makeatother

\usepackage{babel}
\begin{document}

When I adding the code above to this, it's doesn't work...

migrated from stackoverflow.com Jul 16 '13 at 18:10

This question came from our site for professional and enthusiast programmers.

  • Care to explain a bit more? Some code that demonstrates your problem? I don't understand your question. For instance, what do you mean by "part"? – joergl Jul 16 '13 at 11:31
  • I posted a simple code..:-) – heblyx Jul 16 '13 at 11:51
  • Load package babel earlier. Option hebrew loads rlbabel.def that overwrites \@part. The patch of werner's answer also works for \@part of rlbabel.def. – Heiko Oberdiek Jul 16 '13 at 21:01
2

The definition that drives the display of \part is actually \@part:

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries \partname\nobreakspace\thepart
       \par\nobreak
     \fi
     \huge \bfseries #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}

The part name and number is set in \Large\bfseries, followed by \par. You can remove this \paragraph break using a patch from etoolbox by adding the following to your document preamble (Document > Settings... > LaTeX Preamble):

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\@part}{\par}{\quad}{}{}
\makeatother

The above patch replaces \par with \quad (a 1em space):

enter image description here

Doesn't look pretty... perhaps you can update the part name/number to math the font of the part title through another preamble addition:

\renewcommand{\partname}{\huge Part}

enter image description here

A similar output is obtained by adding the following patch with the previous one:

\patchcmd{\@part}{\Large}{\huge}{}{}

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.