奇怪的 \parbox 问题:垂直定位

奇怪的 \parbox 问题:垂直定位

我正在更新我的简历并将其转换为基于 LaTeX 的 CV。我正在重复使用我喜欢的几个开放模板的功能,但我正在尝试根据自己的品味和内容修改文档。长话短说,目前我遇到了一个奇怪的问题,其中的内容(我的研究人员标识符)\parbox由于某种原因从预期的垂直位置向下错位。我希望得到帮助来解决这个问题。问题的图片和相关的 MWE 如下。PS 如果您想要我的二维码图像文件,请告诉我。

问题:

在此处输入图片描述

代码(MWE):

\documentclass[12pt]{article}
\RequirePackage[T1]{fontenc}

\usepackage{charter}
\usepackage{calc}
\usepackage[shortcuts]{extdash}

\reversemarginpar

\usepackage[paper=a4paper,
  marginparwidth=30.5mm,
  marginparsep=1.5mm,
  margin=25mm,
  includemp]{geometry}

\setlength{\parindent}{0in}

\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}

% I wasn't sure, if I could omit 'fancyhdr'-related
% code for the MWE purposes, so included just in case
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}

\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfootoffset{\marginparsep+\marginparwidth}
\newlength{\footpageshift}
\setlength{\footpageshift}
{0.5\textwidth+0.5\marginparsep+0.5\marginparwidth-2in}
\lfoot{\hspace{\footpageshift}%
  \parbox{4in}{\, \hfill %
    \arabic{page} of \protect\pageref*{LastPage}
    \hfill \,}}

\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
  linkcolor=darkblue,urlcolor=darkblue,
  anchorcolor=darkblue,citecolor=darkblue}

\newcommand{\makeheading}[2][]%
{\hspace*{-\marginparsep minus \marginparwidth}%
  \begin{minipage}[t]{\textwidth+\marginparwidth+\marginparsep}%
    {\large \bfseries #2 \hfill #1}\\[-0.15\baselineskip]%
    \rule{\columnwidth}{2pt}%
  \end{minipage}}

\renewcommand{\section}[1]{\pagebreak[3]%
  \vspace{1.3\baselineskip}%
  \phantomsection\addcontentsline{toc}{section}{#1}%
  \noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth}{\hyphenpenalty=10000\raggedright #1}}}%
  \vspace{-\baselineskip}\par}

\usepackage{url}
\urlstyle{same}

\providecommand*\emaillink[1]{\nolinkurl{#1}}
\providecommand*\email[1]{\href{mailto:#1}{\emaillink{#1}}}


\begin{document}
  \makeheading{Aleksandr~L.~Blekh}

  \section{Contact Information}

  \newlength{\rcollength}\setlength{\rcollength}{1.85in}%
  \newlength{\spacewidth}\setlength{\spacewidth}{20pt}
  %
  \begin{tabular}[t]{@{}p{\textwidth-\rcollength-\spacewidth}@{}p{\spacewidth}@{}p{\rcollength}}%

    % Address box
    \parbox{\textwidth-\rcollength-\spacewidth}{%
      \textit{Mobile:} +1-111-111-1111 \\
      \textit{E-mail:} \email{[email protected]} \\
      \textit{E-mail:} \email{[email protected]} \\
      \textit{Web:\ \ \ \ } \href{http://www.aleksandrblekh.com}{www.aleksandrblekh.com}
    }

    &
    {\vrule width 0.5pt}
    \parbox[m][5\baselineskip]{\spacewidth}{} &

    \parbox{\rcollength}{
      \href{http://linkedin.com/in/ablekh}{LinkedIn}\\
      \href{https://www.researchgate.net/profile/Aleksandr_Blekh}{ResearchGate}\\
      \href{http://quora.com/Aleksandr-Blekh}{Quora}\\
      \href{http://stackexchange.com/users/3422261/aleksandr-blekh?tab=accounts}{StackExchange}\\
      \href{https://github.com/abnova}{GitHub}
    }

  \end{tabular}


  \section{Researcher Identification}

  \begin{tabular}[t]{@{}p{\textwidth-\rcollength-\spacewidth}@{}p{\spacewidth}@{}p{\rcollength}}%

    \parbox{\textwidth-\rcollength-\spacewidth}{%
      \textit{ORCID:\ \ \ \ \ \ \ \ \ } 0000-0003-4596-8376 $\rightarrow$ \\
      \textit{ResearcherID:} P-1489-2014
    }

    &
    %{\vrule width 0.5pt}
    \parbox[m][5\baselineskip]{\spacewidth}{} &

    \parbox{\rcollength}{
      \includegraphics[scale=0.15]{MyOrcidQRcode}
    }

  \end{tabular}

\end{document}

答案1

你还没有说“问题”是什么。如果你不使用任何选项,那么[c]parbox 的对齐点就是其垂直中心。如果你使用,[t]对齐点就是其顶行的基线。

据我所知,\parbox示例代码中都不需要任何内容​​,因为它们只是重复列p

我猜你想要类似的东西

在此处输入图片描述

\documentclass[12pt]{article}
\RequirePackage[T1]{fontenc}

\usepackage{charter}
\usepackage{calc}
\usepackage[shortcuts]{extdash}

\reversemarginpar

\usepackage[paper=a4paper,
  marginparwidth=30.5mm,
  marginparsep=1.5mm,
  margin=25mm,
  includemp]{geometry}

\setlength{\parindent}{0in}

\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}

% I wasn't sure, if I could omit 'fancyhdr'-related
% code for the MWE purposes, so included just in case
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}

\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfootoffset{\marginparsep+\marginparwidth}
\newlength{\footpageshift}
\setlength{\footpageshift}
{0.5\textwidth+0.5\marginparsep+0.5\marginparwidth-2in}
\lfoot{\hspace{\footpageshift}%
  \parbox{4in}{\, \hfill %
    \arabic{page} of \protect\pageref*{LastPage}
    \hfill \,}}

\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
  linkcolor=darkblue,urlcolor=darkblue,
  anchorcolor=darkblue,citecolor=darkblue}

\newcommand{\makeheading}[2][]%
{\hspace*{-\marginparsep minus \marginparwidth}%
  \begin{minipage}[t]{\textwidth+\marginparwidth+\marginparsep}%
    {\large \bfseries #2 \hfill #1}\\[-0.15\baselineskip]%
    \rule{\columnwidth}{2pt}%
  \end{minipage}}

\renewcommand{\section}[1]{\pagebreak[3]%
  \vspace{1.3\baselineskip}%
  \phantomsection\addcontentsline{toc}{section}{#1}%
  \noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth}{\hyphenpenalty=10000\raggedright #1}}}%
  \vspace{-\baselineskip}\par}

\usepackage{url}
\urlstyle{same}

\providecommand*\emaillink[1]{\nolinkurl{#1}}
\providecommand*\email[1]{\href{mailto:#1}{\emaillink{#1}}}


\begin{document}
  \makeheading{Aleksandr~L.~Blekh}

  \section{Contact Information}

  \newlength{\rcollength}\setlength{\rcollength}{1.85in}%
  \newlength{\spacewidth}\setlength{\spacewidth}{20pt}
  %
  \begin{tabular}[t]{@{}p{\textwidth-\rcollength-\spacewidth}@{\hspace{\spacewidth}}p{\rcollength}@{}}%

    % Address box
      \textit{Mobile:} +1-111-111-1111 \newline
      \textit{E-mail:} \email{[email protected]} \newline
      \textit{E-mail:} \email{[email protected]} \newline
      \textit{Web:\ \ \ \ } \href{http://www.aleksandrblekh.com}{www.aleksandrblekh.com}


    &
      \href{http://linkedin.com/in/ablekh}{LinkedIn}\newline
      \href{https://www.researchgate.net/profile/Aleksandr_Blekh}{ResearchGate}\newline
      \href{http://quora.com/Aleksandr-Blekh}{Quora}\newline
      \href{http://stackexchange.com/users/3422261/aleksandr-blekh?tab=accounts}{StackExchange}\newline
      \href{https://github.com/abnova}{GitHub}

  \end{tabular}


  \section{Researcher Identification}

  \begin{tabular}[t]{@{}p{\textwidth-\rcollength-\spacewidth}@{\hspace{\spacewidth}}p{\rcollength}@{}}%

      \textit{ORCID:\ \ \ \ \ \ \ \ \ } 0000-0003-4596-8376 $\rightarrow$ \newline
      \textit{ResearcherID:} P-1489-2014
     &
      \rule{.5cm}{.5cm}%\includegraphics[scale=0.15]{MyOrcidQRcode}


  \end{tabular}

\end{document}

虽然我不会使用ORCID:\ \ \ \ \ \ \ \ \伪对齐,但会使用内部测试的表格来排列这些字段。

使用 atabular避免使用\ \ \ \和添加垂直规则

\documentclass[12pt]{article}
\RequirePackage[T1]{fontenc}

\usepackage{charter}
\usepackage{calc}
\usepackage[shortcuts]{extdash}

\reversemarginpar

\usepackage[paper=a4paper,
  marginparwidth=30.5mm,
  marginparsep=1.5mm,
  margin=25mm,
  includemp]{geometry}

\setlength{\parindent}{0in}

\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}

% I wasn't sure, if I could omit 'fancyhdr'-related
% code for the MWE purposes, so included just in case
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}

\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfootoffset{\marginparsep+\marginparwidth}
\newlength{\footpageshift}
\setlength{\footpageshift}
{0.5\textwidth+0.5\marginparsep+0.5\marginparwidth-2in}
\lfoot{\hspace{\footpageshift}%
  \parbox{4in}{\, \hfill %
    \arabic{page} of \protect\pageref*{LastPage}
    \hfill \,}}

\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
  linkcolor=darkblue,urlcolor=darkblue,
  anchorcolor=darkblue,citecolor=darkblue}

\newcommand{\makeheading}[2][]%
{\hspace*{-\marginparsep minus \marginparwidth}%
  \begin{minipage}[t]{\textwidth+\marginparwidth+\marginparsep}%
    {\large \bfseries #2 \hfill #1}\\[-0.15\baselineskip]%
    \rule{\columnwidth}{2pt}%
  \end{minipage}}

\renewcommand{\section}[1]{\pagebreak[3]%
  \vspace{1.3\baselineskip}%
  \phantomsection\addcontentsline{toc}{section}{#1}%
  \noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth}{\hyphenpenalty=10000\raggedright #1}}}%
  \vspace{-\baselineskip}\par}

\usepackage{url}
\urlstyle{same}

\providecommand*\emaillink[1]{\nolinkurl{#1}}
\providecommand*\email[1]{\href{mailto:#1}{\emaillink{#1}}}


\begin{document}
  \makeheading{Aleksandr~L.~Blekh}

  \section{Contact Information}

  \newlength{\rcollength}\setlength{\rcollength}{1.85in}%
  \newlength{\spacewidth}\setlength{\spacewidth}{20pt}
  %
  \begin{tabular}[t]{@{}p{\textwidth-\rcollength-\spacewidth}@{\hspace{\spacewidth}}p{\rcollength}@{}}%
    \begin{tabular}[t]{@{}ll@{\quad}|}
      \textit{Mobile:}& +1-111-111-1111 \\
      \textit{E-mail:}& \email{[email protected]} \\
      \textit{E-mail:}& \email{[email protected]} \\
      \textit{Web}& \href{http://www.aleksandrblekh.com}{www.aleksandrblekh.com}
      \end{tabular}
     &
      \href{http://linkedin.com/in/ablekh}{LinkedIn}\newline
      \href{https://www.researchgate.net/profile/Aleksandr_Blekh}{ResearchGate}\newline
      \href{http://quora.com/Aleksandr-Blekh}{Quora}\newline
      \href{http://stackexchange.com/users/3422261/aleksandr-blekh?tab=accounts}{StackExchange}\newline
      \href{https://github.com/abnova}{GitHub}

  \end{tabular}


  \section{Researcher Identification}

  \begin{tabular}[t]{@{}p{\textwidth-\rcollength-\spacewidth}@{\hspace{\spacewidth}}p{\rcollength}@{}}%

      \textit{ORCID:\ \ \ \ \ \ \ \ \ } 0000-0003-4596-8376 $\rightarrow$ \newline
      \textit{ResearcherID:} P-1489-2014
     &
      \rule{.5cm}{.5cm}%\includegraphics[scale=0.15]{MyOrcidQRcode}


  \end{tabular}

\end{document}

相关内容