如何让背景从上到下变成灰色?

如何让背景从上到下变成灰色?

我非常喜欢这个简历(第一个截图),我能找到的最接近的简历是这个(第二张截图)。完整的源代码是这里

如果我删除第一tcolorbox部分并preamble.tex设置

\geometry{
  a4paper,
  left=0mm,
  right=7mm,
  bottom=0mm,
  top=0mm
}

灰色填充到左侧和底部,但由于某种原因没有填充顶部。

问题

有人能弄清楚如何才能让灰色一直延伸到纸张的顶部,就像第一张截图中那样吗?

在此处输入图片描述

在此处输入图片描述

答案1

这是一个解决方案(代码preamble.tex来自macros.tex此处的模板:https://www.overleaf.com/project/63dada0a427cf681232e7ed8,但我将这些文件的内容复制在下面,所以我的答案没有链接到外部链接)。

诀窍是反转小页面的顺序(首先是带有侧面板的小页面,并在此侧面板中添加图像,然后是带有主面板的小页面,主面板包含一个带有姓名和联系信息的 tcolorbox,以及个人资料、工作经历等)。

\input{setup/preamble.tex}
\input{setup/macros.tex}

\begin{document}

    %%% Sections %%%

    \tcbset{colframe=white,colback=white,arc=0mm, height=\textheight}
    \begin{tcolorbox}
        \vspace*{-1em}
        \begin{minipage}[t]{0.3\textwidth} % Side Panel (e.g. Skills, Links, Languages, etc.)
            \begin{tcolorbox}[height=\textheight, grow to left by=0.6cm,colback=backdrop,colframe=backdrop,arc=0mm]

                \includegraphics[width=\textwidth]{example-image-a} % Picture
                
                % Skills, the skill level is drawn as bars, input: skill name and an array starting from 0 and ending before 4
                \subsection*{Skills}
                    \skill{Python}{0, 1, 2, 3}
                    \skill{Git}{0, 1, 2}
                    \skill{Linux}{0, 1, 2, 3}
                    \skill{Java}{0, 1, 2, 3, 4}
                    \skill{C++}{0, 1, 2, 3, 4}
                    \skill{LaTeX}{0, 1, 2, 3, 4}

                \subsection*{Languages}
                    \lan{English}{0, 1, 2, 3}
                    \lan{Spanish}{0, 1, 2, 3}
                    \lan{Danish}{0, 1, 2, 3}
            \end{tcolorbox}
        \end{minipage}
        \begin{minipage}[t]{0.7\textwidth} % Main Panel (e.g. Education, Work Experience)
            \begin{tcolorbox}[grow to right by=0.75cm,height=1.00\textheight,colframe=white,colback=white]

    %%% TItle %%%

    \vspace*{-0.75em}
    \begin{tcolorbox}[colframe=title,colback=title,arc=0mm]

        \begin{minipage}{1.00\textwidth} % Name and Contact Info
            \name{John Doe}{Carpe Diem} % Name and Profession
            \vspace{2em}
            \email{[email protected]} $\cdot$
            \phone{+31 555 555 555} \par \vspace{0.5em}
            \address{London, England} $\cdot$
            \github{https://github.com/}{JohnDoe}
        \end{minipage}
        
    \end{tcolorbox}


                % Profile Section
                \section*{Profile}
                    \lipsum[20]

                % Work Experience
                \section*{Work Experience}
                    \work{Mechanical Engineer}{Sep 2026 - Oct 2028}{Some Company}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla ac nisl. Nullam urna nulla, ullamcorper in, interdum sit amet, gravida ut, risus.}

                % Education
                \section*{Education}
                    \education{MSc in Mechanical Engineering}{Sep 2020 - Oct 2024}{Stanford University}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla ac nisl. Nullam urna nulla, ullamcorper in, interdum sit amet, gravida ut, risus.} \vspace{2em}
                    \education{BSc in Electrical Engineering}{Sep 2018 - Oct 2020}{Stanford University}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla ac nisl. Nullam urna nulla, ullamcorper in, interdum sit amet, gravida ut, risus.}

                % Publications
                \section*{Publications}
                    \pub{SplitPotato: A novel approach towards splitting potato chromosomes}{2 June 2022}{Stanford University}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla ac nisl. Nullam urna nulla, ullamcorper in, interdum sit amet, gravida ut, risus.}{https://scholar.google.com/}
            \end{tcolorbox}
        \end{minipage}
    \end{tcolorbox}
    
\end{document}

你会得到:

在此处输入图片描述

编辑

添加内容preamble.texmacros.tex因此答案不链接到外部来源。

序言.tex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[11pt,onesize,a4paper,titlepage]{article}

%%%%%%%%%%%%%%% Formatting %%%%%%%%%%%%%%% 
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{geometry} % Margins
\usepackage{sectsty} % Custom Sections

%%%%%%%%%%%%%%% Font %%%%%%%%%%%%%%% 
\usepackage{Archivo}
\usepackage[T1]{fontenc}

%%%%%%%%%%%%%%% Graphics %%%%%%%%%%%%%%% 
\usepackage{fontawesome5} % Icons
\usepackage{graphicx} % Images
\usepackage[most]{tcolorbox} % Color Box
\usepackage{xcolor} % Colors
\usepackage{tikz} % For Drawing Shapes
\tcbuselibrary{breakable}

%%%%%%%%%%%%%%% Miscelanous %%%%%%%%%%%%%%% 
\usepackage{lipsum} % Lorem Ipsum
\usepackage{hyperref} % For Hyperlinks

%%%%%%%%%%%%%%% Colors %%%%%%%%%%%%%%% 
\definecolor{title}{HTML}{4bfbba} % Color of the title
\definecolor{backdrop}{HTML}{f2f2f2} % Color of the side column
\definecolor{lightgray}{HTML}{b8b8b8} % Color for the skill bars

%%%%%%%%%%%%%%% Section Format %%%%%%%%%%%%%%% 
\sectionfont{                     
    \LARGE % Font size
    \sectionrule{0pt}{0pt}{-8pt}{1pt} % Rule under Section name
}

\subsectionfont{
    \large % Font size
    \fontfamily{phv}\selectfont % Font family
    \sectionrule{0pt}{0pt}{-8pt}{1pt} % Rule under Subsection name
}

%%%%%%%%%%%%%%% Margins and Headers %%%%%%%%%%%%%%%
\geometry{
  a4paper,
  left=7mm,
  right=7mm,
  bottom=10mm,
  top=10mm
}

\pagestyle{empty} % Empty Headers

宏指令

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MACROS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%% Link With an Icon %%%%%%%%%%%%%%% 
\newcommand{\link}[1]{
    \href{#1}{\faIcon{link}}
}

%%%%%%%%%%%%%%% Name Template %%%%%%%%%%%%%%% 
\newcommand{\name}[2]{
    % Name
    \Huge % Font size
    \raggedright \textbf{#1} \par

    \vspace*{0.3cm}
    
    % Profession
    \Large % Font size
    \raggedright #2 \par
    \normalsize \normalfont
}

%%%%%%%%%%%%%%% Contact Details %%%%%%%%%%%%%%%
\newcommand{\info}[2]{
    \faIcon{#2} \hspace{0.2em} #1
}

%%%%%%%%%%%%%%% Email %%%%%%%%%%%%%%%
\newcommand{\email}[1]{
    \info{#1}{envelope}
}

%%%%%%%%%%%%%%% Phone Number %%%%%%%%%%%%%%%
\newcommand{\phone}[1]{
    \info{#1}{mobile-alt}
}

%%%%%%%%%%%%%%% Address %%%%%%%%%%%%%%%
\newcommand{\address}[1]{
    \info{#1}{map-marker-alt}
}

%%%%%%%%%%%%%%% GitHub %%%%%%%%%%%%%%%
\newcommand{\github}[2]{
    \info{\href{#1}{\underline{#2}}}{github}
}

%%%%%%%%%%%%%%% LinkedIn %%%%%%%%%%%%%%%
\newcommand{\linkedin}[2]{
    \info{\href{#1}{\underline{#2}}}{linkedin}
}

%%%%%%%%%%%%%%% Website %%%%%%%%%%%%%%%
\newcommand{\website}[1]{
    \info{#1}{link}
}

%%%%%%%%%%%%%%% Draw Skill Bars %%%%%%%%%%%%%%% 
\newcommand{\drawskillbars}[1]{
    \begin{tikzpicture}
        % Draw 5 gray bars
        \foreach \i in {0, 1, 2, 3, 4}{
            \fill[lightgray] (\i * 0.7 + 0.2 *\i,0) rectangle (0.7 + \i * 0.7 + \i * 0.2,0.1);
        }
        
        % Draw number of black bars depending on the skill level
        \foreach \i in {#1}{
            \fill[black] (\i * 0.7 + 0.2 *\i,0) rectangle (0.7 + \i * 0.7 + \i * 0.2,0.1);
        }
    \end{tikzpicture} \par
}
    
%%%%%%%%%%%%%%% Skills %%%%%%%%%%%%%%%
\newcommand{\skill}[2]{
    % Name of the skill
    \large
    \noindent \hangafter=0
    \textmd{#1}
    \normalsize \par 
    % Skill bars
    \drawskillbars{#2}
    \vspace{1.5em}
}

%%%%%%%%%%%%%%% Language %%%%%%%%%%%%%%%
\newcommand{\lan}[2]{
    % Name of the language
    \large
    \noindent \hangafter=0
    \textmd{#1}
    % Knowledge level
    \drawskillbars{#2}
    \vspace{1em}
 }

%%%%%%%%%%%%%%% Education %%%%%%%%%%%%%%%
\newcommand{\education}[4]{
    % Name of the studies
    \noindent \large \parbox{.7\linewidth}{\textbf{#1}}
    % Duration in a Box
    \hfill \scriptsize
    \tcbox[enhanced,box align=base,nobeforeafter,colback=title,colframe=title,size=fbox,arc=0mm]{\textbf{#2}} \par
    \vspace{0.3em}
    % School Name 
    \large
    \noindent \color{title} \parbox{.7\linewidth}{\textsl{#3}} \par
    % Description
    \normalsize \color{black}
    \vspace*{0.3em}
    \small #4 
    \normalsize \par
}

%%%%%%%%%%%%%%% Work Experience %%%%%%%%%%%%%%%
\newcommand{\work}[4]{
    % Name of the Job
    \noindent \large \parbox{.7\linewidth}{\textbf{#1}}
    % Duration in a Box 
    \hfill \scriptsize
    \tcbox[enhanced,box align=base,nobeforeafter,colback=title,colframe=title,size=fbox,arc=0mm]{\textbf{#2}} \par
    \vspace{0.3em}
    % Name of the Employer
    \noindent \large \color{title} \parbox{.7\linewidth}{\textsl{#3}} \par
    % Description of the job
    \vspace*{0.3em} \color{black}
    \small #4 
    \normalsize \par
}

%%%%%%%%%%%%%%% Publications %%%%%%%%%%%%%%%
\newcommand{\pub}[5]{
    % Title
    \noindent \large \parbox{.7\linewidth}{\textbf{#1} \link{#5}}
    % Publication Date
    \hfill \scriptsize
    \tcbox[enhanced,box align=base,nobeforeafter,colback=title,colframe=title,size=fbox,arc=0mm]{\textbf{#2}} \par
    \vspace{0.3em}
    % Institution
    \large
    \noindent \color{title} \parbox{.7\linewidth}{\textsl{#3}} \par
    % Description
    \vspace*{0.3em} \color{black}
    \small \textit{#4} \par
    \normalsize \par 
}

相关内容