Awesome-CV icon indicating copy to clipboard operation
Awesome-CV copied to clipboard

cvsubentries alignment difference between 1st and subsequent entries (also triggers overfull \hbox)

Open electrofelix opened this issue 3 years ago • 0 comments

I've pulled in #314 locally to fix an issue with the missing trailing doubleslash to signify end of row. However I've noticed that there is still an issue with alignment and that once you have a second cvsubentry start getting warnins about overfull \hbox.

There are a few PRs up trying to solve issues with the cvsubentry including #237, #314, & #335.

I've attached a minimal demo example that demonstrates the issue (appended .txt file entexsion to allow upload): demo.tex.txt

I've found a solution that suggests that tabular* is quite space sensitive.

In addition to including the above PR, I've changed the width of the multicolumn at the end and added both vertical and horizontal bars to help show the alignment issue:

\newcommand*{\cvsubentry}[4]{
  \vspace{-2.0mm}
  \setlength\tabcolsep{0pt}
  \setlength{\extrarowheight}{0pt}
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} | L{\textwidth - 4.5cm} | R{4.5cm} |}
    \hline
    \subentrytitlestyle{#2} & \ifthenelse{\equal{#1}{}}
      {\subentrydatestyle{#3}}{} \\
    \hline
    \ifx\relax#1\relax
    \else
      \subentrypositionstyle{#1} & \subentrydatestyle{#3} \\
    \fi
    \ifx\relax#4\relax
    \else
      \multicolumn{2}{|L{\textwidth-0.2mm}|}{\subdescriptionstyle{#4}} \\
      \hline
    \fi
  \end{tabular*}
}

This produces the following: image

If I modify the above block of code to have % after every line, such as follows:

\newcommand*{\cvsubentry}[4]{%
  \vspace{-2.0mm}%
  \setlength\tabcolsep{0pt}%
  \setlength{\extrarowheight}{0pt}%
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} | L{\textwidth - 4.5cm} | R{4.5cm} |}%
    \hline%
    \subentrytitlestyle{#2} & \ifthenelse{\equal{#1}{}}%
      {\subentrydatestyle{#3}}{} \\%
    \hline%
    \ifx\relax#1\relax%
    \else%
      \subentrypositionstyle{#1} & \subentrydatestyle{#3} \\%
    \fi%
    \ifx\relax#4\relax%
    \else%
      \multicolumn{2}{|L{\textwidth-0.2mm}|}{\subdescriptionstyle{#4}} \\%
      \hline%
    \fi%
  \end{tabular*}
}

Then the result looks like: image

Finally removing the vertical lines so that the block of code becomes:

\newcommand*{\cvsubentry}[4]{%
  \vspace{-2.0mm}%
  \setlength\tabcolsep{0pt}%
  \setlength{\extrarowheight}{0pt}%
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} L{\textwidth - 4.5cm} R{4.5cm}}%
    \hline%
    \subentrytitlestyle{#2} & \ifthenelse{\equal{#1}{}}%
      {\subentrydatestyle{#3}}{} \\%
    \hline%
    \ifx\relax#1\relax%
    \else%
      \subentrypositionstyle{#1} & \subentrydatestyle{#3} \\%
    \fi%
    \ifx\relax#4\relax%
    \else%
      \multicolumn{2}{L{\textwidth-0.2mm}}{\subdescriptionstyle{#4}} \\%
      \hline%
    \fi%
  \end{tabular*}
}

And the overfull \hbox warning goes away (obviously can also be solved by allowing some space for them to exist in the table column widths.

This suggests that tabular* is quite space sensitive. I've tried removing the % from the end of the lines between \newcommand*{\cvsubentry}[4]{% \nd \begin{tabular*}.... and both the alignment and hbox overfull issues re-appear.

Not entirely sure, why this only affects the cvsubentries and not the cventry, possibly because cvsubentries is a nested tabular* entry, so extra space from the subentries are picked up and added by the outer tabular* to subsequent rows?

This unfortunately doesn't solve a vertical spacing issue that appears when I add a 3rd cvsubentry to the code and I see the following: image

Switching the initial \vspace{-2.0mm} from the start of each \cvsubentry to the start of the cvsubentries environment does however appear to produce a more consistent spacing:

% Define an environment for cvsubentry
\newenvironment{cvsubentries}{%
  \vspace{-3mm}
  \begin{center}
}{%
  \end{center}
}

\newcommand*{\cvsubentry}[4]{%
  \setlength\tabcolsep{0pt}%
  \setlength{\extrarowheight}{0pt}%
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} L{\textwidth - 4.5cm}| R{4.5cm}}%
    \hline%
    \setlength\leftskip{0.2cm}%
    \subentrytitlestyle{#2} & \ifthenelse{\equal{#1}{}}%
      {\subentrydatestyle{#3}}{} \\%
    \hline%
    \ifx\relax#1\relax%
    \else%
      \subentrypositionstyle{#1} & \subentrydatestyle{#3} \\%
    \fi%
    \ifx\relax#4\relax%
    \else%
      \multicolumn{2}{L{\textwidth-0.2mm}}{\subdescriptionstyle{#4}} \\%
      \hline%
    \fi%
  \end{tabular*}
}

Produces the following which avoids the overlapping veritical alignment image

I think a couple of things can be done to make the alignment around cvsubentries consistent depending on whether these are of interest:

  1. If the \ifx\relax<item>\relax... syntax is consistent across various engines, it seems like it would be useful to update both cventry and cvsubentry to use that form instead of the \ifthenelse.... Could #314 be merged and then a subsequent one added to do the same for cventry?
  2. A PR to place % at the end of all lines between the \begin{tabular*} and \end{tabular*} would help reduce risk of some formatting issues coupled with some comments to alert users as to why.
  3. Finally switch from using \vspace in each cvsubentry to using \vspace in the cvsubentries environment. Possibly if there is another entry similar to \vspace{\acvSectionContentTopSkip} then would still have the vspace{-2.0mm} in the individual \cvsubentry.

electrofelix avatar Feb 22 '21 14:02 electrofelix