That seems to be mostly a Trek thing, though. In reality, most large ships the size of the Enterprise would have multiple Captains, each in charge of departments. The skipper would either also be a Captain, or possibly an Admiral.
Well... Nuclear aircraft carriers have distorted this somewhat, one because they are so big, and two because of the career timelines for officers to become qualified to command them. When an officer is assigned as XO of a CVN, he (or she) is most likely a senior commander and will soon make captain's rank on the job. So "The Captain" is a captain, but years senior to the captain who is the XO. Likewise in the air wing, though that's a separate command. The reactor officer is also often a captain, because the job requires extensive command experience. Staff corps department heads like medical, dental and chaplain might be captains, but the majority of department heads are commanders.
On most other ships it's more clear cut: if the CO is a captain, the XO will be a commander and the department heads commanders or lieutenant commanders. If the CO is a commander, everything drops one rank down. Except for CG's; the navy has gone back and forth between captains and commanders for their COs. If it's a captain, the XO will usually be a lieutenant commander, the same as on a destroyer since the CGs are really puffed up DDGs.
So if Janeway finds a ship, and she assigns it a skeleton crew, and for what ever convoluted reason, puts ensign Harry Kim in charge of that ship to complete the mission, Would that force the other officers, even those who are higher than ensign, to call Harry "captain"?
That's the kind of thing that would never be an issue in real life. The most senior officer who could be spared would be sent to take charge of the other vessel, and the rest of the personnel assigned would be junior to him/her. The use of the title "captain" would be kind of a gray area, but being a temporary arrangement I think most people would prefer not to use it.
Justin