Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Ho can I make a section command that have the same spaces between the \titlerule and the title of the original \section command? The overall look must be equal to the original \section command. So, Is it better use the \titlerule command insted of the \rule command?

P.S. In the picture below I have forgotten a "to", sorry.

enter image description here

\documentclass[a4paper,cleardoublepage=empty,oneside,openany,final,10pt]{scrbook}

\usepackage{titlesec}

\newcommand*{\Section}[1]{%
\textsc{#1}\newline%
\rule{\textwidth}{.4pt}\newline%
\normalsize%
\normalfont%
\vspace*{.4\baselineskip}%
\large%
\textit{Curriculum Vit\ae}%
\normalsize\normalfont%
}

\titleformat{\section}{\large\raggedright}{}{0em}{\scshape}[\titlerule\normalsize\normalfont\vspace*{.4\baselineskip}\large\textit{Curriculum Vit\ae}\normalsize\normalfont]

\begin{document}

\section{Mario Rossi}

\vspace*{50pt}

\Section{Mario rossi}

\end{document}
share|improve this question
add comment

2 Answers

One way to define your command would be like this:

\newcommand{\Section}[1]{\bigskip\noindent\bgroup\large\textsc{#1}\hfil\break
\vskip-8pt\hrule\vskip6pt\noindent\textit{Curriculum Vit\ae}\egroup\par}

and then adjust the two vskips as you want them, to get the right spacing around the rule.

share|improve this answer
    
The manual control via 8pt/6pt can be avoided by using strut. It much clearer and of course it uses the current font size. –  Marco Daniel May 10 '13 at 11:55
add comment

The baseline of rule must be shifted. Therefor you can use the optional argument of rule:

\documentclass[a4paper,cleardoublepage=empty,oneside,openany,final,10pt]{scrreprt}
\newcommand*{\Section}[1]{%
\noindent\textsc{#1}\newline%
\rule[0.5\ht\strutbox]{\textwidth}{.4pt}\newline%
\normalsize%
\normalfont%
\vspace*{.4\baselineskip}%
\large%
\textit{Curriculum Vit\ae}%
\normalsize\normalfont%
}
\begin{document}
\Section{Mario rossi}
\end{document}

By the way: I don't think that scrbook is really a good choice for a CV. I think scrartcl is more suitable.

share|improve this answer
    
I can see the difference in the spacing only by looking at it. How can I set the spacing at the same value of that provided from titlesec package in a automatic manner not only by looking at it? I have tryed to look into the scrbook.cls and the titlesec.sty files to find the correct spacing factor but I have not find it... –  FormlessCloud May 10 '13 at 12:46
    
@FormlessCloud: Which space do you mean? –  Marco Daniel May 10 '13 at 12:52
    
Please, look at the picture in my question. However I mean the space between "Mario Rossi" and the rule as well the space between the rule and "Curriculum Vitae" –  FormlessCloud May 10 '13 at 13:02
    
@FormlessCloud: Do you mean \titleformat{\section}{\large\raggedright}{}{0em}{\scshape}[\titlerule\vspace*{‌​\dp\strutbox}\normalsize\normalfont\large\textit{Curriculum Vit\ae}\normalsize\normalfont] –  Marco Daniel May 10 '13 at 13:36
    
oh sorry, yeah the upper one in my picture is from the original section command, and the other below is from the custom section command like I have typed the commands in my MWE. However, yes I mean that I would to copy the spaces from the original section command, customized by the titlesec package with the \titleformat command –  FormlessCloud May 10 '13 at 15:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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