如何將某些文字與徽標對齊?

如何將某些文字與徽標對齊?

我正在嘗試將一些文字與徽標右對齊,即我想將一些文字放置在徽標的左側,並將該文字相對於徽標垂直居中。

我附上了一份 pdf 文件,以便更清楚地了解我正在嘗試做的事情。

我想將“Faculty of Science”文字放置在上面 pdf 中黑色“徽標”的左側。在本例中,藍色矩形邊框距頁面邊緣 1 厘米,2.5 厘米寬的方形標誌距藍色矩形邊框 1.25 毫米。

我認為 textpos 是我想要做的事情的解決方案,我想出了下面的程式碼。

\documentclass{article}

% ...

\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{\TPHorizModule}
\textblockorigin{0mm}{0mm} % start everything at the top-left corner

\begin{document}

% ...

\begin{textblock}{100}[0,0](120, 23.75)

\large \textit{\textbf{Faculty of Science}}

\end{textblock}

% ...

\end{document}

但是,我想要的東西無論我希望放置什麼文本都可以工作(即最後一個單詞的最右邊的字母應該始終與徽標保持相同的固定距離,例如 1 厘米,並且還應該相對於徽標垂直居中)標識)。在這裡,每次我更改文字或其樣式時,我都必須擺弄座標,直到我得到看起來正確的東西。

有任何想法嗎?

答案1

您可以minipage為此使用 s

螢幕截圖

請注意,minipage環境採用強制<width>參數和可選position參數。我以前的[c]意思是centred在下面。

我用了一個空盒子,\mbox{}這樣\hfill就有東西可以抵住。

根據需要調整寬度,不要忘記demographicx包裝中取出選購品。

\documentclass{article}
\usepackage[showframe=true]{geometry}
\usepackage[demo]{graphicx}

\begin{document}

\mbox{}\hfill
\begin{minipage}[c]{4cm}
Faculty of science
\end{minipage}%
\hspace{1cm} % your specified distance
\begin{minipage}{4cm}
  \includegraphics[width=\textwidth]{yourimagename}
\end{minipage}

\mbox{}\hfill
\begin{minipage}[c]{4cm}
Faculty of science
Faculty of science
Faculty of science
Faculty of science
Faculty of science
\end{minipage}% 
\hspace{1cm} % your specified distance
\begin{minipage}{4cm}
  \includegraphics[width=\textwidth]{yourimagename}
\end{minipage}
\end{document}

請注意%第一個 s 末尾的 ,minipage以避免插入額外的空格。

答案2

另一個選擇是使用 coffinfsxcoffins包裹:

\documentclass{article}
\usepackage[margin=1cm,showframe=true]{geometry}
\usepackage[demo]{graphicx}% just for the example
\usepackage{xcoffins}
\usepackage{lipsum}% just to generate some text for the example

\newlength\logosz
\setlength\logosz{2.5cm}
\newlength\logosep
\setlength\logosep{1.25mm}

\begin{document}

% coffins allocation
\NewCoffin \Result
\NewCoffin \Institution
\NewCoffin \Logo

% fill the coffins
\SetHorizontalCoffin \Result{}
\SetVerticalCoffin \Institution{7cm} {\noindent\raggedleft Faculty of Science}
\SetVerticalCoffin \Logo{2.5cm} {\vspace*{\logosep}\noindent\includegraphics[width=\logosz,height=\logosz]{logo}}

% Join the coffins
\JoinCoffins \Result \Logo(\textwidth-\logosz-\logosep,10pt)
\JoinCoffins \Result[\Logo-vc,\Logo-l] \Institution [vc,r](-1cm,0pt)

% Typeset \Result
\noindent\TypesetCoffin \Result

\lipsum[1-4]

\end{document}

在此輸入影像描述

在棺材中添加更多文字\Institution仍然保留垂直對齊以及1cm\Logo棺材的分離:

\documentclass{article}
\usepackage[margin=1cm,showframe=true]{geometry}
\usepackage[demo]{graphicx}
\usepackage{xcoffins}
\usepackage{lipsum}

\newlength\logosz
\setlength\logosz{2.5cm}
\newlength\logosep
\setlength\logosep{1.25mm}

\begin{document}

% coffins allocation
\NewCoffin \Result
\NewCoffin \Institution
\NewCoffin \Logo

% fill the coffins
\SetHorizontalCoffin \Result{}
\SetVerticalCoffin \Institution{7cm} {\noindent\raggedleft Faculty of Science Faculty of Science Faculty of Science Faculty of Science Faculty of Science Faculty of Science Faculty of Science}
\SetVerticalCoffin \Logo{2.5cm} {\vspace*{\logosep}\noindent\includegraphics[width=\logosz,height=\logosz]{logo}}

% Join the coffins
\JoinCoffins \Result \Logo(\textwidth-\logosz-\logosep,10pt)
\JoinCoffins \Result[\Logo-vc,\Logo-l] \Institution [vc,r](-1cm,0pt)

% Typeset \Result
\noindent\TypesetCoffin \Result

\lipsum[1-4]

\end{document}

在此輸入影像描述

demo選項graphicx簡單地將實際圖形替換為黑色矩形;做不是在您的實際文件中使用該選項。

相關內容