How do I put a logo on the first page of a LaTeX document?

Asked 2 years ago, Updated 2 years ago, 122 views

I would like to put a small logo image in the upper left corner of the first page of the Japanese document I wrote in LaTeX. How can I write this down?

For now,

\title {secret documentation}
\author
\date{December 26, 2014}

and then

\begin { document }
\makeetitle

Generating title pages in

latex

2022-09-30 20:29

3 Answers

(There may be a more elegant solution) I'll write down the way I came up with:

\ documentclass {book}
\uspackage {graphicx}
\title{%
\begin {figure} [!t]%
\makebox[\textwidth][l]{\smash{%
\begin {picture} (0,0)
\put(-100,50){\includegraphics[width=2cm]{image file}}
\end {picture}}}
\end {figure}%
TOP SECRET}

\author {OverFlow}
\date{Dec.26th, 2014}
\begin { document }
\makeetitle

\end { document }

Description:

Depending on the style file, \maketitle will change the page, so I decided to specify it in \title to make sure it appears on the same page as the title.The only purpose is to display it on the same page, so you can specify it in \author or \date instead of \title.(However, it may be a problem if there is a style file that extracts a string from \title,etc. as metadata.)

\begin{figure}[!t] uses the top of the page as the base position of the logo (otherwise the title position will be based on the length of the title), and \makebox&\smash uses \begin{figure} to destroy the next page.

\begin{picture}&\put(X,Y) is used to fine-tune the position, where X is the amount of movement to the right and Y is the amount of movement to the up.A decimal number is fine.Please use this part to fine-tune the position.


2022-09-30 20:29

In the end, you will use graphicx as in other answer examples, but you will use a device called pagestyle to specify a style to place on the page.

For pagestyle, call \pagestyle {markedpage} and so on, but if you only want to change the page on which the macro appears, say \thispagestyle {markedpage}.

Now, running \pagestyle {markedpage} actually invokes the macro \ps@markedpage.You define this macro yourself, but you define a macro for outputting headers and/or footers.For example, in article.cls, the style headings is defined as follows (to invoke headings, write \pagestyle {headings}):

\if@twoside
  \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
    \def\sectionmark##1{%
      US>\markboth{\MakeUppercase{%
        \ifnum\c@secnumdepth>\z@
          \thesection\quad
        \fi
        ##1}}{}}%
    \def\subsectionmark##1{%
      \markright{%
        \ifnum\c@secnumdepth>\@ne
          \thesubsection\quad
        \fi
        ##1}}}
\else
  \def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\sectionmark##1{%
      US>\markright{%
        \ifnum\c@secnumdepth>\m@ne
          \thesection\quad
        \fi
        ##1}}}}
\fi

This includes a variety of even page odd pages that are defined for different use, but for example, you can rewrite \@oddhead, which defines an even page header, define a macro with the name \ps@markedpage, and call it \thispagestyle{markedpage}

In order to write in the body of the text, you have to use \makeatletter and \makeatother (you cannot use @), so be careful. If you don't know this, you may want to check how to write a style file.


2022-09-30 20:29

\makeetitle

where

\ documentclass {article}

For , defined in article.cls.

To change the appearance of a title, you can use titlepage instead of \makeetitle.For example, when you want to insert a logo.

The following example uses pdflatex+CJK package to write Japanese in UTF-8.
Also, use graphicx package to display the logo.

Provide logo.png for the logo.

%filename: foo.tex
\ documentclass {article}
\uspackage {CJK}
\uspackage {graphicx}
\begin { document }
\begin {titlepage}
% logo
\includegraphics {logo.png}\\[1cm]
\begin {CJK} {UTF8} {min}
\begin {center}
% title
{\LARGE Confidential \\[1cm]
% author
Large Windbreaker}\\[1cm]
% date
US>Large December 26, 2014} 
\end {center}
\end {CJK}
\end {titlepage}
\end { document }

I decided the size of ad-hoc directly to cm or mm, but I think I can get the desired result by adjusting it at any time.

%pdflatex foo.tex

LaTeX Documentation logo

So far, we have referred to LaTeX/Title Creation.

Alternatively, you can use a different package.Please search:

  • titting package
  • fancyhdr package


2022-09-30 20:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.