LaTeX forum ⇒ Text FormattingMake custom title Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Hermano
Posts: 14
Joined: Wed Apr 06, 2011 9:10 pm

Make custom title

Postby Hermano » Thu May 16, 2013 11:19 am

Dear all,

This is maybe a stupid question but I can not find how to define a preamble for my own (custom) title "\boldtitle". I can not use \maketitle as this gives me errors. It will be used as a sort of section but without numbering.

  1. \newcommand\boldtitle{?????}
  2.  
  3. \begin{document}
  4.  
  5. \boldtitle{[b]This is my title[/b]}
  6.  
  7. \end{document}


I want the title in bold that is left aligned an that has a defined white space before and after.

Thanks!
Last edited by cgnieder on Thu May 16, 2013 11:34 am, edited 1 time in total.
Reason: added code markup

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Thu May 16, 2013 11:39 am

Hermano wrote:This is maybe a stupid question but I can not find how to define a preamble for my own (custom) title "\boldtitle". I can not use \maketitle as this gives me errors. It will be used as a sort of section but without numbering.


I don't really understand: do you want to customize the title that is made by \title, \author and \maketitle or do you want an unnumbered section (\section*{I'm not numbered})?

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links

Hermano
Posts: 14
Joined: Wed Apr 06, 2011 9:10 pm

Postby Hermano » Thu May 16, 2013 12:43 pm

I don't want to customize the title made by \title etc.
I want to create my own "title/heading" for a section which is not numbered and also not in the table of contents.

I can make it easily like:

  1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \\
  2.  
  3. \noindent{\textbf{This is my title}} \\
  4.  
  5. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.


But as I will use this format for a "title" many times, I want to create a preamble named "\boldtitle" such it looks like:

  1. \boldtitle{This is my title}


In this preamable, I want to define the spacings before and after the title, bold text, not numbered, left aligned and not in taken into account for the table of contents.
Last edited by cgnieder on Thu May 16, 2013 1:10 pm, edited 1 time in total.
Reason: added code markup

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Thu May 16, 2013 1:13 pm

Hermano wrote:I want to create my own "title/heading" for a section which is not numbered and also not in the table of contents.


There's already a command for this: the starred version of \section:

  1. \section*{Unnumbered section that will not appear in the ToC}


BTW: you shouldn't use \\ to terminate a paragraph. An empty line in the source suffices. \\ does not terminate a paragraph, anyway, but ends a line, which is a different thing.

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links

Hermano
Posts: 14
Joined: Wed Apr 06, 2011 9:10 pm

Postby Hermano » Thu May 16, 2013 2:15 pm

Dear cgnieder,

Thanks for the answer!
However, using \section*{} will make the fontsize bigger than the rest of my text. Is there a way to specify the size once for whole my document for the \section*{} command in such a way it doesn't influence the fontsize of the \section{} command?
Last edited by cgnieder on Thu May 16, 2013 6:10 pm, edited 1 time in total.
Reason: added code markup

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Thu May 16, 2013 6:22 pm

You could adapt the definition of \section from article.cls. The code below defines a macro \mycustomhead which works exactly like \section except that it uses \normalsize instead of \large. I also defined a second command \myhead that simply calls the starred variant of \mycustomhead in order to get an unnumbered heading without entry in the ToC:

  1. \documentclass{article}
  2. \usepackage[T1]{fontenc}
  3.  
  4. \makeatletter
  5. \newcommand\mycustomhead{%
  6. \@startsection{section}{1}{\z@}%
  7. {-3.5ex \@plus -1ex \@minus -.2ex}%
  8. {2.3ex \@plus.2ex}%
  9. {\normalfont\normalsize\bfseries}}
  10. \newcommand\myhead[1]{\mycustomhead*{#1}}
  11. \makeatother
  12.  
  13. \usepackage{lipsum}% dummy text
  14.  
  15. \begin{document}
  16.  
  17. \section{test}
  18. \lipsum[1]
  19.  
  20. \myhead{custom head}
  21. \lipsum[1]
  22.  
  23. \end{document}


Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode: Topic is solved[/url]" title="Click to select post's link in BBcode format" onclick="this.focus();this.select();" />
HTML: Topic is solved</a>" title="Click to select post's link in HTML format" onclick="this.focus();this.select();" />
Hide post links
Show post links

Hermano
Posts: 14
Joined: Wed Apr 06, 2011 9:10 pm

Postby Hermano » Thu May 16, 2013 11:08 pm

Thanks cgnieder for your clear answer! This solved mu problem!

Thanks

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests