TransWikia.com

Directly including Reference for CV inplace, however, each line shifting right

TeX - LaTeX Asked by Rio1210 on December 21, 2020

I am really struggling to put together a CV which can use a .bib file and I can directly enter inline reference, without citing somewhere in the document.

I used one of the examples from this site stackexchange to include references directly in place for a CV. The toy example worked fine, however, when using it with my .cls file, the publications section seems to be shifted to the right-side of the paper a little bit. Any help would be greatly appreciated. I have put together a minimal working example to demonstrate this.

Overleaf MWE link:
Overleaf Link

Please let me know if anything else is needed.

Edit:
I am also attaching the code for the MWE:

res.cls file

typeout{Document Style `res' <26 Sep 89>.}

NeedsTeXFormat{LaTeX2e}[1995/12/01]
ProvidesClass{res}[2000/05/19 v1.4b Resume class]

PassOptionsToClass{11pt,12pt}{article}
LoadClassWithOptions{article}

newifif@line
newifif@margin

DeclareOption{line}{@linetrue}
DeclareOption{centered}{@linefalse}

DeclareOption{margin}{@margintrue}
DeclareOption{overlapped}{@marginfalse}

ExecuteOptions{overlapped,centered}
ProcessOptionsrelax

nofiles         %



newtokstabular@text           % holds the current list being processed
newtokstabular@head           % holds the head tabular list
newtokstabular@tail           % holds the tail tabular list
newtoks@ta                % used by @append
newtoksundefined@tokenundefined@token={}

    
typeout{Document Style `res' <26 Sep 89>.}

NeedsTeXFormat{LaTeX2e}[1995/12/01]
ProvidesClass{res}[2000/05/19 v1.4b Resume class]

PassOptionsToClass{11pt,12pt}{article}
LoadClassWithOptions{article}

newifif@line
newifif@margin

DeclareOption{line}{@linetrue}
DeclareOption{centered}{@linefalse}

DeclareOption{margin}{@margintrue}
DeclareOption{overlapped}{@marginfalse}

ExecuteOptions{overlapped,centered}
ProcessOptionsrelax

nofiles         % resume's don't need .aux files


newtokstabular@text           % holds the current list being processed
newtokstabular@head           % holds the head tabular list
newtokstabular@tail           % holds the tail tabular list
newtoks@ta                % used by @append
newtoksundefined@tokenundefined@token={}


def@printcentername{begingroup
  % print the name centered
  leavevmodehbox to textwidth{hfil@tablebox{namefont@name}hfil}par
  @ifundefined{@addressone}{%
    % do nothing
  }{%
    @ifundefined{@addresstwo}{
      % only one address
      leavevmodehbox to textwidth{hfil@tablebox{@addressone}hfil}par
    }{
      % two addresses
      leavevmodehbox to textwidth{@tablebox{@addressone}hfil
                     @tablebox{@addresstwo}}par
    }%
  }%
endgroup}

defnamefont{largebf}
def@linename{begingroup
  def{, }
  {namefont@name}
  vskip 2pt
  fullline
  vskip 2pt
  % where do you live?
  @ifundefined{@addressone}{%
    % do nothing
  }{%
    leavevmodehbox to textwidth
      {hfillvbox{hbox{@addressone}
           hbox{@addresstwo}
          }%
      }par
  }
endgroup}

letprint@namerelax
defds@centered{ifxprint@namerelaxletprint@name@printcenternamefi}
defds@line{ifxprint@namerelaxletprint@name@linenamefi}

defsectionfont{bf}
newdimensectionwidth
newskipsectionskip
newdimenresumewidth

resumewidth=6.5in
sectionskip=3.5ex plus 1ex minus -.2ex % values stolen from LaTeX

defnewsectionwidth#1{%
             sectionwidth=#1
             textwidth=resumewidth
             advancetextwidth-sectionwidth
             hsize=textwidth
             hoffset=sectionwidth
}


defboxed@sectiontitle#1{%

  % ...
  ifx@tabcr    % is this in a tabular? (this *should* work but is a cludge)
    @stopfield    % the is the first part of a kill
   else
     @@par      % This will end the previous paragraph if needed and
           % go into vertical mode.  If this was already in
           % vertical mode then the par does nothing.

  fi
  begingroup
  everypar={}%
  defpar{@@par}%
  let=@normalcr
  addpenalty{@secpenalty} % this would be a good place for a page break
                % @secpenalty is what LaTeX uses before its
                % section's.  It happens to be -300
  addvspace{sectionskip}  % put in a bit of glue

  hbox to 0pt{%
    hss     % this is an llap.  In other words, this glue
         % will shrink by the width of the stuff in the vbox
         % (sectionwidth) into the left margin and then
         % insert the contents of the vbox.
    vtop to 0pt{% make a 0pt height paragraph, with the baseline at the
         % lined up with the baseline of the first box in the list
      leftskip=0pt
      hsize=sectionwidth
      textwidth=sectionwidth
      raggedright     % you don't want this filled out to the right margin
      sectionfont
      #1vss           % Go into horizontal mode; do the paragraph;
               % go into vertical mode; add some negative glue 
               % to give a box of 0pt height and depth
    }%
  }%
  addpenalty{-@secpenalty} % this would be a bad place for a page break
  vskip-baselineskip % when the next box is processed, baselineskip glue

  endgroup
  ifx@tabcr   
    @startline
    ignorespaces
  else
    vskip-parskip    
  fi
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is for sectiontitles that are entirely above the section text
%
defunboxed@sectiontitle#1{%
  ifx@tabcr % see boxed@sectiontitle for explation
    @stopfield
   else
     @@par
  fi
  begingroup
  everypar={}%
  defpar{@@par}%
  def{ }
  addpenalty{@secpenalty}
  addvspace{sectionskip}
  hbox to 0pt{hsshbox to sectionwidth{sectionfont#1hss}}
  addpenalty{-@secpenalty} % this would be a bad place for a page break
  endgroup
  ifx@tabcr   % see boxed@sectiontitle for explation
    @startline
  else
    vskip-parskip
  fi
  ignorespaces
}

let@@sectionrelax
defds@overlapped{ifx@@sectionrelaxnewsectionwidth{0.5in}let
  @@sectionunboxed@sectiontitlefi}
defds@margin{ifx@@sectionrelaxnewsectionwidth{1.3in}let
  @@sectionboxed@sectiontitlefi}

%input article.sty

if@lineds@lineelseds@centeredfi
if@marginds@marginelseds@overlappedfi


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% typeset resume all nice and pretty
%
defResume{{R'{e}sum'{e}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% makes a line of width textwidth starting at -hoffset
%
deffullline{      % hrules only listen to hoffset
  nointerlineskip  % so I have this code     
  movelefthoffsetvbox{hrule widthtextwidth} 
  nointerlineskip
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create a multiline box.
%
def@tablebox#1{begin{tabular}[t]{@{}l@{extracolsep{fill}}}#1end{tabular}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use this to define your name
%
defname#1{def@name{#1}}

def@name{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use this to define your address, this may be called more than once.
%
let@addressonerelax
let@addresstworelax

defaddress#1{
  @ifundefined{@addressone}{def@addressone{#1}}{def@addresstwo{#1}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

defopening{def@opening{}
  begingroup
  leftskip=-hoffset        % I use leftskip to move things to the left as 
  advancetextwidthhoffset % changing hoffset doesn't work. But this
  hsize=textwidth      % doesn't really work as hboxes are rules
                 % are unaffeted
  letpar=@@par
  parindent=0pt
  parskip=0pt
  print@name
  endgroup
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% all of the resume goes in the resume environment
%
newenvironment{resume}{begingroup
               @ifundefined{@opening}{opening}{}
}{endgroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
def@endpbox{paregrouphfil}
let@@endpbox=@endpbox

newdimen@columnwidth    % the width of each column equal to
defncolumn#1{%
  % @columnwidth = textwidth / #1
  @columnwidth=textwidth divide@columnwidth by #1
  begin{tabular*}{textwidth}[t]%
    {*{#1}{@{}p{@columnwidth}@{extracolsep{fill}}}}
}

defendncolumn{end{tabular*}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

defemployer#1{def@employer{print@employer{#1}}}
deflocation#1{def@location{print@location{#1}}}
defdates#1{def@dates{print@dates{#1}}}
deftitle#1{def@title{print@title{#1}}}

letl@justifyraggedright
letr@justifyraggedleft
letc@justifycentering


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

def@format#1#2{%
  expandaftergdefcsname print@#1endcsname##1{%
    {csname#2@justifyendcsname##1par}}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


newcounter{numberofcolumns}
newenvironment{format}{%
  defend@line@head{append@tabular@head{tabular@text}tabular@text={}%
    c@numberofcolumns 0}
  defend@line@tail{append@tabular@tail{tabular@text}tabular@text={}%
    c@numberofcolumns 0}
  tabular@text={}
  tabular@head={}
  tabular@tail={}
  c@numberofcolumns 0
  let=end@line@head
  defemployer##1{advancec@numberofcolumns 1
           @format{employer}{##1}
           append@tabular@text{employer}}
  deflocation##1{advancec@numberofcolumns 1
           @format{location}{##1}
           append@tabular@text{location}}
  defdates##1{advancec@numberofcolumns 1
        @format{dates}{##1}
        append@tabular@text{dates}}
  deftitle##1{advancec@numberofcolumns 1
         @format{title}{##1}
        append@tabular@text{title}}
  defbody{iftokstabular@headundefined@tokenthen
        else
          @append{noexpand}totabular@head
        skotfi
        let=end@line@tail}}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%taken from page 378 of TeXbook but freely hacked
%
% appends the expansion of #1 to the token list #2

def@append#1to#2{%
  @ta=expandafter{#1}%
  xdef@append@temp{the#2the@ta}
  global#2=expandafter{@append@temp}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CHAA006%[email protected]
% texhax.88.078
% is used to see if two token lists are equal
% there must be a better way
%

let then = empty
def iftoks #1#2then #3else #4skotfi{
        edef 1{the #1}
        edef 2{the #2}
        ifx 12then #3else #4fi}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


defappend@tabular@text#1{%
iftokstabular@textundefined@tokenthen
  globaltabular@text=expandafter{csname @#1endcsname}
else
  @append{&}totabular@text
  @append{csname @#1endcsname}totabular@text
skotfi
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
defappend@tabular@head#1{%
  ifnumthec@numberofcolumns=0relax
  else
    iftokstabular@headundefined@tokenthen
      relax
    else
      @append{noexpand}totabular@head
      @append{noexpandpenalty-@secpenalty}totabular@head
    skotfi
    @append{noexpandbegin{ncolumn}}totabular@head
    @append{expandafter{thec@numberofcolumns}}totabular@head
    @append{thecsname#1endcsname}totabular@head
    @append{noexpandend{ncolumn}}totabular@head
  fi
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
defappend@tabular@tail#1{%
  ifnumthec@numberofcolumns=0relax
  else
    iftokstabular@tailundefined@tokenthen
    else
      @append{noexpand}totabular@tail
      @append{noexpandpenalty-@secpenalty}totabular@tail
    skotfi
    @append{noexpandbegin{ncolumn}}totabular@tail
    @append{expandafter{thec@numberofcolumns}}totabular@tail
    @append{thecsname#1endcsname}totabular@tail
    @append{noexpandend{ncolumn}}totabular@tail
  fi
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

newenvironment{position}%
  {%
   begingroup
     par
       thetabular@head
%     addpenalty{-@secpenalty}% bad place for a page break
     penalty -@secpenalty % bad place for a page break
     penalty 10000
     ignorespaces
  }{%
       thetabular@tail
%     addpenalty{@secpenalty}% good place for a page break
     penalty @secpenalty % good place for a page break
    endgroup
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


@secpenalty = -500
topmargin 0pt
headheight 0pt
headsep 0pt
textheight 9in
parindent 0pt
topmargin 0in
oddsidemargin 0pt
evensidemargin 0pt
marginparwidth 0pt
parindent 0pt
parskip baselineskip
setcounter{secnumdepth}{0}
def@listI{leftmarginleftmargini
topsep 0pt 
parskip 0pt
partopsep 2pt plus 2pt
parsep 2pt plus 2pt
itemsep parsep}

pagestyle{empty}  % don't want page numbers

begin{format}
title{l}employer{r}
location{l}dates{r}
body
end{format}

letsection@@section

Code for main.tex file:

% documentclass[10pt,a4paper]{article}
documentclass[10pt, a4paper]{res}

% use your favourite citation style here
usepackage{apacite}

usepackage[left=2.5cm,right=2.5cm,top=1.5cm,bottom=2.5cm]{geometry}

usepackage{bibentry}
makeatletterletsaved@bibitem@bibitemmakeatother
usepackage[colorlinks=true]{hyperref}
makeatletterlet@bibitemsaved@bibitemmakeatother


% hanging publications: 1st line starts at beginning of line, 
% further lines are placed a bit to the right
% usepackage{hanging}
% newcommandpublication[1]{%
%   smallskipparhangpara{1.5em}{1}bibentry{#1}smallskip
% }

usepackage{hanging}
newcommandpublication[1]{%
    smallskipparhangpara{1.5em}{1}bibentry{#1}smallskip
}


begin{document}
    
    % bibliography
    nobibliography{publications.bib}
    bibliographystyle{apacite} 

    section{Publications}  
    
    % optional: split into different subsections for
    % peer-reviewed articles, conference abstracts, ...

    % example with links
    publication{Geirhos2017}
        (href{https://arxiv.org/abs/1706.06969}{link}, href{https://arxiv.org/pdf/1706.06969.pdf}{pdf}, href{https://github.com/rgeirhos/object-recognition}{data and materials})
    
    % example without links
    publication{Knuth1998}
    
    % the cumbersome way
%   hangpara{1.5em}{1}Knuth, D. E. (1998). 
%   textit{The art of computer programming: sorting and searching} (Vol. 3). Pearson Education.
    
end{document}

And a toy publications.bib file:

@article{Geirhos2017,
  title={Comparing deep neural networks against humans: object recognition when the signal gets weaker},
  author={Geirhos, Robert and Janssen, David HJ and Sch{"u}tt, Heiko H and Rauber, Jonas and Bethge, Matthias and Wichmann, Felix A},
  journal={arXiv preprint arXiv:1706.06969},
  year={2017}}

@book{Knuth1998,
  title={The art of computer programming: sorting and searching},
  author={Knuth, Donald Ervin},
  volume={3},
  year={1998},
  publisher={Pearson Education}}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP